#endif
) {
if(!dt_io_thread_start(dtenv->dtio, comm_base_internal(
- worker->base))) {
+ worker->base), worker->daemon->num)) {
log_err("could not start dnstap io thread");
worker_delete(worker);
return 0;
{
struct dt_io_list_item* item = malloc(sizeof(*item));
if(!item) return 0;
+ lock_basic_lock(&mq->lock);
mq->dtio = dtio;
+ lock_basic_unlock(&mq->lock);
item->queue = mq;
item->next = dtio->io_list;
dtio->io_list = item;
if(prev) prev->next = item->next;
else dtio->io_list = item->next;
/* the queue itself only registered, not deleted */
+ lock_basic_lock(&item->queue->lock);
item->queue->dtio = NULL;
+ lock_basic_unlock(&item->queue->lock);
free(item);
dtio->io_list_iter = NULL;
return;
struct dt_io_thread* dtio = (struct dt_io_thread*)arg;
time_t secs = 0;
struct timeval now;
+ log_thread_set(&dtio->threadnum);
/* setup */
verbose(VERB_ALGO, "start dnstap io thread");
}
#endif /* THREADS_DISABLED */
-int dt_io_thread_start(struct dt_io_thread* dtio, void* event_base_nothr)
+int dt_io_thread_start(struct dt_io_thread* dtio, void* event_base_nothr,
+ int numworkers)
{
/* set up the thread, can fail */
#ifndef USE_WINSOCK
#endif
/* start the thread */
+ dtio->threadnum = numworkers+1;
dtio->started = 1;
#ifndef THREADS_DISABLED
ub_thread_create(&dtio->tid, dnstap_io, dtio);
* IO thread that reads from the queues and writes them.
*/
struct dt_io_thread {
+ /** the thread number for the dtio thread,
+ * must be first to cast thread arg to int* in checklock code. */
+ int threadnum;
/** event base, for event handling */
void* event_base;
/** list of queues that is registered to get written */
* @param event_base_nothr: the event base to attach the events to, in case
* we are running without threads. With threads, this is ignored
* and a thread is started to process the dnstap log messages.
+ * @param numworkers: number of worker threads. The dnstap io thread is
+ * that number +1 as the threadnumber (in logs).
* @return false on failure.
*/
-int dt_io_thread_start(struct dt_io_thread* dtio, void* event_base_nothr);
+int dt_io_thread_start(struct dt_io_thread* dtio, void* event_base_nothr,
+ int numworkers);
/**
* Stop the io thread