From 8d4a61a789a910f044fc04f7c9909905121a5db5 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 29 Oct 2013 00:10:38 +0100 Subject: [PATCH] Counters: remove unused code --- src/counters.c | 109 ++----------------------------------------------- src/counters.h | 4 -- 2 files changed, 3 insertions(+), 110 deletions(-) diff --git a/src/counters.c b/src/counters.c index e9670cd259..9b6772559f 100644 --- a/src/counters.c +++ b/src/counters.c @@ -239,9 +239,6 @@ static void SCPerfInitOPCtx(void) } } - /* club the counter from multiple instances of the tm before o/p */ - sc_perf_op_ctx->club_tm = 1; - /* init the lock used by SCPerfClubTMInst */ if (SCMutexInit(&sc_perf_op_ctx->pctmi_lock, NULL) != 0) { SCLogError(SC_ERR_INITIALIZATION, "error initializing pctmi mutex"); @@ -653,7 +650,6 @@ static void SCPerfOutputCalculateCounterValue(SCPerfCounter *pc, void *cvalue_op */ static int SCPerfOutputCounterFileIface() { - ThreadVars *tv = NULL; SCPerfClubTMInst *pctmi = NULL; SCPerfCounter *pc = NULL; SCPerfCounter **pc_heads = NULL; @@ -661,7 +657,6 @@ static int SCPerfOutputCounterFileIface() uint64_t ui64_temp = 0; uint64_t ui64_result = 0; - struct timeval tval; struct tm *tms; @@ -701,40 +696,6 @@ static int SCPerfOutputCounterFileIface() fprintf(sc_perf_op_ctx->fp, "----------------------------------------------" "---------------------\n"); - if (sc_perf_op_ctx->club_tm == 0) { - for (u = 0; u < TVT_MAX; u++) { - tv = tv_root[u]; - //if (pc_heads == NULL || pc_heads[u] == NULL) - // continue; - - while (tv != NULL) { - SCMutexLock(&tv->sc_perf_pctx.m); - pc = tv->sc_perf_pctx.head; - - while (pc != NULL) { - if (pc->value == NULL) { - pc = pc->next; - continue; - } - - SCPerfOutputCalculateCounterValue(pc, - &ui64_temp); - fprintf(sc_perf_op_ctx->fp, "%-25s | %-25s | " - "%-" PRIu64 "\n", pc->name->cname, - pc->name->tm_name, ui64_temp); - - pc = pc->next; - } - - SCMutexUnlock(&tv->sc_perf_pctx.m); - tv = tv->next; - } - fflush(sc_perf_op_ctx->fp); - } - - return 1; - } - pctmi = sc_perf_op_ctx->pctmi; while (pctmi != NULL) { if ((pc_heads = SCMalloc(pctmi->size * sizeof(SCPerfCounter *))) == NULL) @@ -764,12 +725,8 @@ static int SCPerfOutputCounterFileIface() if (pc_heads[u] != NULL) pc_heads[u] = pc_heads[u]->next; - - if (pc_heads[u] == NULL || - (pc_heads[0] != NULL && - strcmp(pctmi->tm_name, pc_heads[0]->name->tm_name))) { - flag = 0; - } + if (pc_heads[u] == NULL) + flag = 1; } if (pc->value == NULL) @@ -819,62 +776,6 @@ TmEcode SCPerfOutputCounterSocket(json_t *cmd, return TM_ECODE_FAILED; } - if (sc_perf_op_ctx->club_tm == 0) { - json_t *tm_array; - - tm_array = json_object(); - if (tm_array == NULL) { - json_object_set_new(answer, "message", - json_string("internal error at json object creation")); - return TM_ECODE_FAILED; - } - - - for (u = 0; u < TVT_MAX; u++) { - tv = tv_root[u]; - //if (pc_heads == NULL || pc_heads[u] == NULL) - // continue; - - - while (tv != NULL) { - SCMutexLock(&tv->sc_perf_pctx.m); - pc = tv->sc_perf_pctx.head; - json_t *jdata; - int filled = 0; - jdata = json_object(); - if (jdata == NULL) { - json_decref(tm_array); - json_object_set_new(answer, "message", - json_string("internal error at json object creation")); - SCMutexUnlock(&tv->sc_perf_pctx.m); - return TM_ECODE_FAILED; - } - - while (pc != NULL) { - if (pc->value == NULL) { - pc = pc->next; - continue; - } - - SCPerfOutputCalculateCounterValue(pc, - &ui64_temp); - json_object_set_new(jdata, pc->name->cname, json_integer(ui64_temp)); - filled = 1; - pc = pc->next; - } - - SCMutexUnlock(&tv->sc_perf_pctx.m); - if (filled == 1) { - json_object_set_new(tm_array, tv->name, jdata); - } - tv = tv->next; - } - } - - json_object_set_new(answer, "message", tm_array); - return TM_ECODE_OK; - } - json_t *tm_array; tm_array = json_object(); @@ -927,12 +828,8 @@ TmEcode SCPerfOutputCounterSocket(json_t *cmd, if (pc_heads[u] != NULL) pc_heads[u] = pc_heads[u]->next; - - if (pc_heads[u] == NULL || - (pc_heads[0] != NULL && - strcmp(pctmi->tm_name, pc_heads[0]->name->tm_name))) { + if (pc_heads[u] == NULL) flag = 0; - } } if (pc->value == NULL) diff --git a/src/counters.h b/src/counters.h index d5e4dd779b..8a72cacac2 100644 --- a/src/counters.h +++ b/src/counters.h @@ -172,10 +172,6 @@ typedef struct SCPerfOPIfaceContext_ { /* more interfaces to be supported later. For now just a file */ FILE *fp; - /* indicates whether the counter values from the same threading module - * should be clubbed or not, during output */ - uint32_t club_tm; - SCPerfClubTMInst *pctmi; SCMutex pctmi_lock; } SCPerfOPIfaceContext;