counters: improve thread setup error handling

pull/14398/head
Victor Julien 11 months ago
parent 33589e6079
commit c89d01679f

@ -1166,7 +1166,10 @@ static int StatsThreadRegister(const char *thread_name, StatsPublicThreadContext
stats_ctx->counters_id_hash = HashTableInit(256, CountersIdHashFunc, stats_ctx->counters_id_hash = HashTableInit(256, CountersIdHashFunc,
CountersIdHashCompareFunc, CountersIdHashCompareFunc,
CountersIdHashFreeFunc); CountersIdHashFreeFunc);
BUG_ON(stats_ctx->counters_id_hash == NULL); if (stats_ctx->counters_id_hash == NULL) {
SCMutexUnlock(&stats_ctx->sts_lock);
return 0;
}
} }
StatsCounter *pc = pctx->head; StatsCounter *pc = pctx->head;
while (pc != NULL) { while (pc != NULL) {
@ -1177,11 +1180,12 @@ static int StatsThreadRegister(const char *thread_name, StatsPublicThreadContext
BUG_ON(id == NULL); BUG_ON(id == NULL);
id->id = counters_global_id++; id->id = counters_global_id++;
id->string = pc->name; id->string = pc->name;
#ifdef DEBUG_VALIDATION int r = HashTableAdd(stats_ctx->counters_id_hash, id, sizeof(*id));
DEBUG_VALIDATE_BUG_ON(HashTableAdd(stats_ctx->counters_id_hash, id, sizeof(*id)) < 0); DEBUG_VALIDATE_BUG_ON(r < 0);
#else if (r < 0) {
HashTableAdd(stats_ctx->counters_id_hash, id, sizeof(*id)); SCMutexUnlock(&stats_ctx->sts_lock);
#endif return 0;
}
} }
pc->gid = id->id; pc->gid = id->id;
pc = pc->next; pc = pc->next;

Loading…
Cancel
Save