Пример #1
0
int chdir_for_file(char const *dir, bool is_filename)
{
    char *redir;
    if (is_filename) {
        redir = tempstr_printf("%s", dir);
        char *last_slash = redir;
        for (char *c = redir; *c; c++) if (*c == '/') last_slash = c;
        *last_slash = '\0';
    } else {
        redir = (char *)dir;
    }

    SLOG(LOG_DEBUG, "chdir into '%s'", redir);
    if (redir[0] == '\0') return 0;

    if (0 != chdir(redir)) {
        SLOG(LOG_ERR, "Cannot chdir(%s) : %s", redir, strerror(errno));
        return -1;
    }

    return 0;
}
Пример #2
0
static enum proto_parse_status tns_parse_login_property(struct sql_proto_info *info, struct cursor *cursor)
{
    SLOG(LOG_DEBUG, "Parsing tns login property");
    // We are only interested in response
    if (info->is_query) return PROTO_OK;
    if (info->msg_type != SQL_UNKNOWN && info->msg_type != SQL_STARTUP) return PROTO_PARSE_ERR;

    // Drop Server version
    DROP_FIX(cursor, 3);
    // Drop Server version text
    uint8_t marker = 0x00;
    enum proto_parse_status status = cursor_drop_until(cursor, &marker, sizeof(marker));
    if (status != PROTO_OK) return status;
    // Drop Null byte
    DROP_FIX(cursor, 1);
    CHECK(2);
    uint16_t charset = cursor_read_u16le(cursor);
    SLOG(LOG_DEBUG, "Found a charset of 0x%02x", charset);
    switch (charset) {
        case 0x01:
        case 0x02:
        case 0x1f:
        case 0xb2:
            sql_set_encoding(info, SQL_ENCODING_LATIN1);
            break;
        case 0x366:
        case 0x367:
        case 0x369:
            sql_set_encoding(info, SQL_ENCODING_UTF8);
            break;
        default:
            SLOG(LOG_DEBUG, "Unknown charset");
            break;
    }
    // We don't care of the rest...
    cursor_drop(cursor, cursor->cap_len);
    return PROTO_OK;
}
Пример #3
0
static gid_t get_gid(const char * const group)
{
    assert(group);

    gid_t gid = getgid(); // default one

    struct group *g = getgrnam(group);
    if (NULL == g)
        SLOG(LOG_ERR, "getgrnam: can't get the uid of '%s'", group);
    else
        gid = g->gr_gid;

    return gid;
}
Пример #4
0
static int netbios_parser_ctor(struct netbios_parser *netbios_parser, struct proto *proto)
{
    SLOG(LOG_DEBUG, "Constructing netbios_parser@%p", netbios_parser);
    assert(proto == proto_netbios);
    if (0 != parser_ctor(&netbios_parser->parser, proto)) return -1;
    netbios_parser->msg_parser = NULL;
    timeval_reset(&netbios_parser->first_packet_tv[0]);
    timeval_reset(&netbios_parser->first_packet_tv[1]);
    if (0 != streambuf_ctor(&netbios_parser->sbuf, netbios_sbuf_parse, 30000, NULL)) {
        parser_dtor(&netbios_parser->parser);
        return -1;
    }
    return 0;
}
Пример #5
0
ssize_t file_size(char const *file_name)
{
    int fd = file_open(file_name, O_RDONLY);
    if (fd < 0) return -1;

    off_t sz = lseek(fd, 0, SEEK_END);
    if (sz == (off_t)-1) {
        SLOG(LOG_ERR, "Cannot lseek at end of '%s' : %s", file_name, strerror(errno));
        return -1;
    }

    file_close(fd);
    return sz;
}
Пример #6
0
static enum proto_parse_status rtp_parse(struct parser *parser, struct proto_layer *parent, unsigned way, uint8_t const *packet, size_t cap_len, size_t wire_len, struct timeval const *now, proto_okfn_t *okfn)
{
    SLOG(LOG_DEBUG, "Starting RTP analysis");

    /* Parse */
    struct rtp_header *rtph = (struct rtp_header *)packet;
    if (wire_len < sizeof(*rtph)) return PROTO_PARSE_ERR;
    if (cap_len < sizeof(*rtph)) return PROTO_TOO_SHORT;

    SLOG(LOG_DEBUG, "RTP header, version=%u, CSRC_count=%u, payload_type=%u",
        rtph->version, rtph->csrc_count, rtph->payload_type);

    size_t head_len = sizeof(*rtph) + rtph->csrc_count * 4;
    if (wire_len < head_len) return PROTO_PARSE_ERR;
    if (cap_len < head_len) return PROTO_TOO_SHORT;

    struct rtp_proto_info info;
    rtp_proto_info_ctor(&info, rtph, head_len, wire_len - head_len);
    struct proto_layer layer;
    proto_layer_ctor(&layer, parent, parser, &info.info);

    return proto_parse(NULL, &layer, way, NULL, 0, 0, now, okfn);
}
Пример #7
0
static int 
log_x25_facilities (int fd, int coc, char *caption)
{
	FACILITY_DB f;

	if (ioctl (fd, X25_RD_FACILITY, (char *) &f) == NOTOK) {
		SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_RD_FACILITY"));
		return NOTOK;
	}

	print_x25_facilities (f, coc, caption);

	return OK;
}
Пример #8
0
void on_unload(void)
{
    SLOG(LOG_INFO, "Duplicogram unloading");

    term_fini();

    hook_subscriber_dtor(&dup_hook, &dup_subscription);
    hook_subscriber_dtor(&proto_cap->hook, &cap_subscription);
    cli_unregister(duplicogram_opts);
    //mutex_dtor(&dup_lock); no since we can have some callbacks called even after we unsubscribed (in another thread)

    ext_param_bucket_width_fini();
    log_category_duplicogram_fini();
}
Пример #9
0
int ip_addr_ctor_from_str_any(struct ip_addr *ip, char const *str)
{
    if (1 == inet_pton(AF_INET, str, &ip->u.v4)) {
        ip->family = AF_INET;
        return 0;
    }
    if (1 == inet_pton(AF_INET6, str, &ip->u.v6)) {
        ip->family = AF_INET6;
        return 0;
    }

    SLOG(LOG_WARNING, "Cannot convert string to IP address: %s", strerror(errno));
    return -1;
}
Пример #10
0
/* CRelationMgr::Insert()和CRelationMgr::Remove()时调用,
   用于添加网关上下线记录。
*/
bool CClientInfo::AddOnoffRecord(const char * name, char * add, int onoff)
{
	char sql_line_exist[NORMAL_XG_BUF_LEN];
	int sql_len_exist = _snprintf_s(sql_line_exist, NORMAL_XG_BUF_LEN-1, _TRUNCATE,
		"SELECT COUNT(*) FROM %s WHERE serial='%s'", m_onoff_record_table, name);
	sql_line_exist[sql_len_exist] = '\0';
	SLOG(4)("AddOnoffRecord = %s", sql_line_exist);
	MYSQL_RES * existresults = BeginQuery(sql_line_exist);
	if (NULL == existresults)
	{
		return FALSE;
	}
	int recordnum = strtoul(*mysql_fetch_row(existresults), NULL, 0);
	EndQuery(existresults);
	if( recordnum == 120)		// 如果已有的该网关上下线记录等于120条
	{
		SLOG(4)("此处应当删除前21条记录");		
		DelOnoffRecord(name);
	}
	InsertOnoffRecord(name, add, onoff);

	return TRUE;
}
Пример #11
0
static enum proto_parse_status rtp_parse(struct parser *parser, struct proto_info *parent, unsigned way, uint8_t const *packet, size_t cap_len, size_t wire_len, struct timeval const *now, size_t tot_cap_len, uint8_t const *tot_packet)
{
    SLOG(LOG_DEBUG, "Starting RTP analysis");

    /* Parse */
    struct rtp_hdr *rtph = (struct rtp_hdr *)packet;
    if (wire_len < sizeof(*rtph)) return PROTO_PARSE_ERR;
    if (cap_len < sizeof(*rtph)) return PROTO_TOO_SHORT;

    unsigned const version = READ_U8(&rtph->flags0) >> 6U;
    unsigned const csrc_count = READ_U8(&rtph->flags0) & F0_CSRC_COUNT_MASK;
    unsigned const payload_type = READ_U8(&rtph->flags1) & F1_PLD_TYPE_MASK;
    SLOG(LOG_DEBUG, "RTP header, version=%u, CSRC_count=%u, payload_type=%u", version, csrc_count, payload_type);

    size_t head_len = sizeof(*rtph) + csrc_count * 4;
    if (wire_len < head_len) return PROTO_PARSE_ERR;
    if (cap_len < head_len) return PROTO_TOO_SHORT;

    struct rtp_proto_info info;
    rtp_proto_info_ctor(&info, parser, parent, rtph, head_len, wire_len - head_len);

    return proto_parse(NULL, &info.info, way, NULL, 0, 0, now, tot_cap_len, tot_packet);
}
Пример #12
0
static int ftw_copy_link(const struct FTW *p,
                         const char *spath,
                         const struct stat *sstp,
                         int exists)
{
    int len;
    char llink[PATH_MAX];

    if ((len = readlink(spath, llink, sizeof(llink) - 1)) == -1) {
        SLOG("readlink: %s: %s", spath, strerror(errno));
        return (1);
    }
    llink[len] = '\0';
    if (exists && unlink(to.p_path)) {
        SLOG("unlink: %s: %s", to.p_path, strerror(errno));
        return (1);
    }
    if (symlink(llink, to.p_path)) {
        SLOG("symlink: %s: %s", llink, strerror(errno));
        return (1);
    }
    return (pflag ? setfile(sstp, -1) : 0);
}
Пример #13
0
static Eina_Bool __tts_notify_utt_completed(void *data)
{
	tts_h tts = (tts_h)data;

	tts_client_s* client = tts_client_get(tts);

	/* check handle */
	if (NULL == client) {
		SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Fail to notify utt completed : A handle is not valid");
		return EINA_FALSE;
	}

	if (NULL != client->utt_completeted_cb) {
		SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of utterance completed \n");
		tts_client_use_callback(client);
		client->utt_completeted_cb(client->tts, client->utt_id, client->utt_completed_user_data);
		tts_client_not_use_callback(client);
	} else {
		SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of utterance completed \n");
	}

	return EINA_FALSE;
}
Пример #14
0
static Eina_Bool __tts_notify_state_changed(void *data)
{
	tts_h tts = (tts_h)data;

	tts_client_s* client = tts_client_get(tts);

	/* check handle */
	if (NULL == client) {
		SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error : A handle is not valid");
		return EINA_FALSE;
	}

	if (NULL != client->state_changed_cb) {
		tts_client_use_callback(client);
		client->state_changed_cb(client->tts, client->before_state, client->current_state, client->state_changed_user_data); 
		tts_client_not_use_callback(client);
		SLOG(LOG_DEBUG, TAG_TTSC, "State changed callback is called");
	} else {
		SLOG(LOG_WARN, TAG_TTSC, "[WARNING] State changed callback is null");
	}

	return EINA_FALSE;
}
Пример #15
0
static Eina_Bool __tts_notify_error(void *data)
{
	tts_h tts = (tts_h)data;

	tts_client_s* client = tts_client_get(tts);

	/* check handle */
	if (NULL == client) {
		SLOG(LOG_WARN, TAG_TTSC, "Fail to notify error : A handle is not valid");
		return EINA_FALSE;
	}

	if (NULL != client->error_cb) {
		SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
		tts_client_use_callback(client);
		client->error_cb(client->tts, client->utt_id, client->reason, client->error_user_data );
		tts_client_not_use_callback(client);
	} else {
		SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error \n");
	}

	return EINA_FALSE;
}
Пример #16
0
void CSocket::socketSystemDestroy()
{
//	errorOut("debuglog.txt", ":: Destroying socket system...");
#if defined(_WIN32) || defined(_WIN64)
	int intTimeCheck = 0;

	while (intTimeCheck++ < 3)
	{
		if (WSACleanup() == SOCKET_ERROR)
			SLOG("[CSocket::socketSystemDestroy] WSACleanup() returned error: %s\n", errorMessage(identifyError()));
		sleep(1000);
	}
#endif
}
int ttsd_server_initialize(int pid, int uid)
{
	if (false == g_is_engine) {
		if (0 != ttsd_engine_agent_initialize_current_engine()) {
			SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] No Engine !!! " );
			g_is_engine = false;

			return TTSD_ERROR_ENGINE_NOT_FOUND;
		} else {
			g_is_engine = true;
		}
	}

	if (-1 != ttsd_data_is_client(uid)) {
		SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Uid has already been registered ");
		return TTSD_ERROR_INVALID_PARAMETER;
	}

	if (0 == ttsd_data_get_client_count()) {
		if (0 != ttsd_engine_agent_load_current_engine()) {
			SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to load current engine ");
			return TTSD_ERROR_OPERATION_FAILED;
		}
	}

	if (0 != ttsd_data_new_client(pid, uid)) {
		SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to add client info ");
		return TTSD_ERROR_OPERATION_FAILED;
	}

	if (0 != ttsd_player_create_instance(uid)) {
		SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] Fail to create player ");
		return TTSD_ERROR_OPERATION_FAILED;
	}

	return TTSD_ERROR_NONE;
}
Пример #18
0
Файл: sip.c Проект: rixed/junkie
static int callid_2_sdp_ctor(struct callid_2_sdp *c2s, char const *call_id, struct timeval const *now)
{
    SLOG(LOG_DEBUG, "Construct callid_2_sdp@%p for callid '%s'", c2s, call_id);
    c2s->sdp_parser = proto_sdp->ops->parser_new(proto_sdp);
    if (! c2s->sdp_parser) return -1;
    memset(c2s->call_id, 0, sizeof c2s->call_id); // because it's used as a hash key
    snprintf(c2s->call_id, sizeof(c2s->call_id), "%s", call_id);
    c2s->last_used = *now;
    mutex_lock(&callids_2_sdps_mutex);
    callids_2_sdps_timeout(now);
    HASH_INSERT(&callids_2_sdps, c2s, &c2s->call_id, entry);
    TAILQ_INSERT_TAIL(&callids_2_sdps_used, c2s, used_entry);
    mutex_unlock(&callids_2_sdps_mutex);
    return 0;
}
Пример #19
0
int tts_get_max_text_count(tts_h tts, int* count)
{
	if (NULL == tts || NULL == count) {
		SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : Input parameter is null");
		return TTS_ERROR_INVALID_PARAMETER;
	}

	tts_client_s* client = tts_client_get(tts);

	if (NULL == client) {
		SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : A handle is not valid");
		return TTS_ERROR_INVALID_PARAMETER;
	}
	
	if (TTS_STATE_READY != client->current_state) {
		SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get max text count : Current state is NOT 'READY'."); 
		return TTS_ERROR_INVALID_STATE;
	}

	*count = MAX_TEXT_COUNT;

	SLOG(LOG_DEBUG, TAG_TTSC, "[Suceess] Get max text count");
	return TTS_ERROR_NONE;
}
Пример #20
0
void ip_addr_deserialize(struct ip_addr *addr, uint8_t const **buf)
{
    unsigned version = deserialize_1(buf);
    if (version == 4) {
        addr->family = AF_INET;
        addr->u.v4.s_addr = deserialize_4(buf);
    } else if (version == 6) {
        addr->family = AF_INET6;
        deserialize_n(buf, &addr->u.v6, sizeof(addr->u.v6));
    } else {
        SLOG(LOG_ERR, "Cannot deserialize ip_addr of version %u", version);
        addr->family = AF_INET; // run forest, run!
        addr->u.v4.s_addr = 0U;
    }
}
Пример #21
0
static void __my_sig_child(int signo, siginfo_t *info, void *data)
{
	int status;
	pid_t child_pid, child_pgid;

	child_pgid = getpgid(info->si_pid);
	SLOG(LOG_DEBUG, TAG_TTSC, "Signal handler: dead pid = %d, pgid = %d\n", info->si_pid, child_pgid);

	while (0 < (child_pid = waitpid(-1, &status, WNOHANG))) {
		if(child_pid == child_pgid)
			killpg(child_pgid, SIGKILL);
	}

	return;
}
Пример #22
0
static int tds_parser_ctor(struct tds_parser *tds_parser, struct proto *proto)
{
    SLOG(LOG_DEBUG, "Constructing tds_parser@%p", tds_parser);
    assert(proto == proto_tds);
    if (0 != parser_ctor(&tds_parser->parser, proto)) return -1;
    tds_parser->msg_parser = NULL;
    tds_parser->had_gap = false;
    tds_parser->data_left = 0;
    tds_parser->channels[0] = 0;
    tds_parser->channels[1] = 0;
    tds_parser->pkt_number = 1;
    if (0 != streambuf_ctor(&tds_parser->sbuf, tds_sbuf_parse, 30000, NULL)) return -1;

    return 0;
}
Пример #23
0
void*
CD_RunHTTPd (CDHTTPd* self)
{
    self->event.handle = evhttp_bind_socket_with_handle(self->event.httpd,
                         self->server->config->cache.httpd.connection.bind.ipv4,
                         self->server->config->cache.httpd.connection.port);

    SLOG(self->server, LOG_NOTICE, "Started HTTPd at http://%s:%d",
         self->server->config->cache.httpd.connection.bind.ipv4,
         self->server->config->cache.httpd.connection.port);

    event_base_dispatch(self->event.base);

    return NULL;
}
Пример #24
0
int 
start_x25_client (struct NSAPaddr *local, int priv)
{
	int     sd;

	if ((sd = socket (AF_X25, SOCK_STREAM, 0)) == NOTOK) {
		SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("socket"));
		return NOTOK;
	}
#ifdef AEF_NSAP
	if (local && local -> na_stack == NA_NSAP) {
		FACILITY f;

		f.type = T_CALLING_AEF;
		if (nsap2if (local, &f.f_calling_aef) == NOTOK ||
				ioctl (sd, X25_SET_FACILITY, &f) == NOTOK) {
			SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("set calling AEF"));
			 close_x25_socket (sd);
			return NOTOK;
		}
	}
#endif
	return sd;
}
Пример #25
0
static enum proto_parse_status parse_rpc_call(struct cursor *cursor, struct rpc_proto_info *info)
{
    CHECK(28);
    info->u.call_msg.rpc_version = cursor_read_u32n(cursor);
    if (info->u.call_msg.rpc_version != 2) {
        SLOG(LOG_DEBUG, "Rpc version should be 2, got %"PRIu32, info->u.call_msg.rpc_version);
        return PROTO_PARSE_ERR;
    }
    info->u.call_msg.program = cursor_read_u32n(cursor);
    info->u.call_msg.program_version = cursor_read_u32n(cursor);
    info->u.call_msg.procedure = cursor_read_u32n(cursor);
    RPC_CHECK_AUTH(credential);
    RPC_CHECK_AUTH(auth);
    return PROTO_OK;
}
Пример #26
0
// Decode the flow in src into flow. We already checked there are enough bytes to read in src.
static int nf_flow_decode(struct nf_flow *flow, struct nf_msg const *head, void const *src)
{
    struct nf_flow_ll const *flow_ll = src; // FIXME: won't work if not properly aligned

    CONV_IP(flow, addr[0]);   CONV_IP(flow, addr[1]);    CONV_IP(flow, next_hop);
    CONV_16(flow, port[0]);   CONV_16(flow, port[1]);
    CONV_16(flow, in_iface);  CONV_16(flow, out_iface);
    CONV_32(flow, packets);   CONV_32(flow, bytes);
    CONV_8(flow, tcp_flags);  CONV_8(flow, ip_proto);    CONV_8(flow, ip_tos);
    CONV_16(flow, as[0]);     CONV_16(flow, as[1]);
    CONV_8(flow, mask[0]);    CONV_8(flow, mask[1]);
    /* The first/last fields of the netflow are the uptime at the first/last pkt of the flow.
     * We find a timestamp more interesting, so we get it from sysuptime and localtime of the header.
     * But this imply trusting the netflow header localtime. */
    SLOG(LOG_DEBUG, "Decoding a flow which sys_uptime=%"PRIu32", now=%s, first=%u, last=%u",
        head->sys_uptime, timeval_2_str(&head->ts), ntohl(flow_ll->first), ntohl(flow_ll->last));
    flow->first = head->ts;
    timeval_sub_usec(&flow->first, (int64_t)(head->sys_uptime - ntohl(flow_ll->first)) * 1000);
    flow->last = head->ts;
    timeval_sub_usec(&flow->last, (int64_t)(head->sys_uptime - ntohl(flow_ll->last)) * 1000);
    SLOG(LOG_DEBUG, "...yielding: %s->%s", timeval_2_str(&flow->first), timeval_2_str(&flow->last));

    return 0;
}
int ttsd_server_pause(int uid, int* utt_id)
{
	app_state_e state;
	if (0 > ttsd_data_get_client_state(uid, &state)) {
		SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] ttsd_server_pause : uid is not valid  ");
		return TTSD_ERROR_INVALID_PARAMETER;
	}

	if (APP_STATE_PLAYING != state)	{
		SLOG(LOG_WARN, TAG_TTSD, "[Server WARNING] Current state is not 'play' ");
		return TTSD_ERROR_INVALID_STATE;
	}

	int ret = 0;
	ret = ttsd_player_pause(uid);
	if (0 != ret) {
		SLOG(LOG_ERROR, TAG_TTSD, "[Server ERROR] fail player_pause() : ret(%d)", ret);
		return TTSD_ERROR_OPERATION_FAILED;
	}

	ttsd_data_set_client_state(uid, APP_STATE_PAUSED);

	return TTSD_ERROR_NONE;
}
Пример #28
0
int 
join_x25_client (int fd, struct NSAPaddr *remote)
{
	CONN_DB     sbuf;
	CONN_DB     *sock = &sbuf;
	int     len = sizeof *sock;
	int     nfd;
#ifdef AEF_NSAP
	FACILITY f;
#endif

	if ((nfd = accept (fd, (struct sockaddr *) sock, &len)) == NOTOK) {
		if (compat_log -> ll_events & LLOG_EXCEPTIONS)
			 log_cause_and_diag(fd);      /* Sun's documentation throwns
						   no light as to whether, or
						   not this will result in any
						   useful information */
	}
#ifdef  DEBUG
	else if (compat_log -> ll_events & LLOG_DEBUG)
		 log_x25_facilities(fd, CALLED, "Effective Called");
#endif
	if (nfd < 0) return nfd;

	/* May also need to send call accept packet if using
	 * FAST_ACPT_CLR, or X25_CALL_ACPT_APPROVAL
	 * there was a SUNLINK bug in this area
	 *
	 * May as well try it -- if it fails, so what ??
	 */
	if (ioctl(nfd,X25_SEND_CALL_ACPT, NULLCP) < 0)
		SLOG (compat_log, LLOG_EXCEPTIONS, "failed", ("X25_SEND_CALL_ACPT"));

#ifdef AEF_NONE /* sunnet 7.0 or > */

	/*
	 * For sunnet 7.0 - see if we have a real nsap and use that.
	 */

	f.type = T_CALLING_AEF;
	if (ioctl (nfd, X25_GET_FACILITY, &f) == NOTOK ||
			if2nsap (&f.f_calling_aef, remote) == NOTOK)
#endif

		remote = if2gen (remote, sock, ADDR_REMOTE);

	return nfd;
}
Пример #29
0
int streambuf_ctor(struct streambuf *sbuf, parse_fun *parse, size_t max_size, struct mutex_pool *pool)
{
    SLOG(LOG_DEBUG, "Constructing a streambuf@%p of max size %zu", sbuf, max_size);

    sbuf->parse = parse;
    sbuf->max_size = max_size;
    sbuf->mutex = mutex_pool_anyone(pool ? pool : &streambuf_locks);

    for (unsigned d = 0; d < 2; d++) {
        sbuf->dir[d].buffer = NULL;
        sbuf->dir[d].buffer_size = 0;
        sbuf->dir[d].restart_offset = 0;
    }

    return 0;
}
Пример #30
0
static bool check_fixed_query(struct cursor *cursor, uint8_t current,
        uint8_t next, struct query_candidate *candidate)
{
    if (is_print(current) && is_print(next)) {
        for (unsigned i = 0; i < candidate->num_candidate_size; ++i) {
            uint64_t size = candidate->candidate_sizes[i];
            if (is_query_valid(cursor, size, 0)) {
                candidate->query_size = candidate->candidate_sizes[i];
                SLOG(LOG_DEBUG, " Found a fixed query string of size %u", candidate->query_size);
                candidate->is_chunked = false;
                return true;
            }
        }
    }
    return false;
}