Beispiel #1
0
void close_wtp(wtp_handle_t* handle) {
    if (!handle)
	{
        errno = EINVAL;
        return;
    }

	wtp_stop_hello_thread(handle);
	if (handle->monitor_thread) pthread_cancel(handle->monitor_thread);
	if (handle->receive_thread) pthread_cancel(handle->receive_thread);
	if (handle->msg_send_producer) pipe_producer_free(handle->msg_send_producer);
	if (handle->msg_send_consumer) pipe_consumer_free(handle->msg_send_consumer);
	if (handle->msg_recv_producer) pipe_producer_free(handle->msg_recv_producer);
	if (handle->msg_recv_consumer) pipe_consumer_free(handle->msg_recv_consumer);
	if (handle->send_thread) pthread_cancel(handle->send_thread);
	if (handle->process_thread) pthread_cancel(handle->process_thread);
	if (handle->udp_socket) close(handle->udp_socket);
	if (handle->wtp_sta_hashmap) hashmapDelete(handle->wtp_sta_hashmap);

	free(handle);
}
Beispiel #2
0
void
dt_delete(dt_env_t *env)
{
	if (!env) return;
	verbose(VERB_OPS, "cleanup dnstap environment");

	free(env->identity);
	free(env->version);

	// Wait for all unbound_workers' producers to drain
	*(env->dt_stopping) = 1;

	pipe_producer_free(env->so_producer);
	pthread_join(env->dt_worker, NULL);
	free(env);
}
Beispiel #3
0
static void* process_pipe(void* param)
{
    connect_data_t p = *(connect_data_t*)param;
    free(param);

    char* buf = malloc(DEFAULT_BUFFER_SIZE * pipe_elem_size(PIPE_GENERIC(p.in)));

    size_t elems_read;

    while((elems_read = pipe_pop(p.in, buf, DEFAULT_BUFFER_SIZE)))
        p.proc(buf, elems_read, p.out, p.aux);

    p.proc(NULL, 0, NULL, p.aux);

    free(buf);

    pipe_consumer_free(p.in);
    pipe_producer_free(p.out);

    return NULL;
}