SCMutexLock(&t->m);
StatsReleaseCounters(t->head);
t->head = NULL;
- t->perf_flag = 0;
+ SC_ATOMIC_SET(t->sync_now, false);
t->curr_id = 0;
SCMutexUnlock(&t->m);
SCMutexDestroy(&t->m);
void StatsSyncCountersIfSignalled(ThreadVars *tv)
{
- if (tv->perf_public_ctx.perf_flag == 1) {
+ if (SC_ATOMIC_GET(tv->perf_public_ctx.sync_now) == true) {
StatsUpdateCounterArray(&tv->perf_private_ctx, &tv->perf_public_ctx);
}
}
continue;
}
- /* assuming the assignment of an int to be atomic, and even if it's
- * not, it should be okay */
- tv->perf_public_ctx.perf_flag = 1;
+ SC_ATOMIC_SET(tv->perf_public_ctx.sync_now, true);
if (tv->inq != NULL) {
PacketQueue *q = tv->inq->pq;
+ SCMutexLock(&q->mutex_q);
SCCondSignal(&q->cond_q);
+ SCMutexUnlock(&q->mutex_q);
}
tv = tv->next;
continue;
}
- /* assuming the assignment of an int to be atomic, and even if it's
- * not, it should be okay */
- tv->perf_public_ctx.perf_flag = 1;
+ SC_ATOMIC_SET(tv->perf_public_ctx.sync_now, true);
tv = tv->next;
}
}
SCMutexUnlock(&pctx->m);
- pctx->perf_flag = 0;
+ SC_ATOMIC_SET(pctx->sync_now, false);
return 1;
}
*/
typedef struct StatsPublicThreadContext_ {
/* flag set by the wakeup thread, to inform the client threads to sync */
- uint32_t perf_flag;
+ SC_ATOMIC_DECLARE(bool, sync_now);
/* pointer to the head of a list of counters assigned under this context */
StatsCounter *head;