in threads.c [87:113]
static void stop_and_wait_for_workers(struct tctl *ctl)
{
int i;
uint64_t total_processed = 0, total_hosts = 0;
for (i = 0; i < ctl->nr_workers; i++) {
pthread_mutex_lock(&ctl->workers[i].queuelock);
ctl->workers[i].stop = 1;
pthread_cond_signal(&ctl->workers[i].cond);
pthread_mutex_unlock(&ctl->workers[i].queuelock);
pthread_join(ctl->workers[i].id, NULL);
pthread_mutex_destroy(&ctl->workers[i].queuelock);
pthread_cond_destroy(&ctl->workers[i].cond);
pthread_condattr_destroy(&ctl->workers[i].condattr);
total_processed += ctl->workers[i].processed;
total_hosts += ctl->workers[i].hosts_seen;
log("Exiting worker %d got %" PRIu64 " msgs from %" PRIu64 " hosts\n",
i, ctl->workers[i].processed,
ctl->workers[i].hosts_seen);
}
log("Total messages processed by workers: %" PRIu64 " from %" PRIu64 " hosts\n",
total_processed, total_hosts);
free(ctl->workers);
}