counters: minor internal API cleanups

pull/1508/head
Victor Julien 10 years ago
parent d2a9ef2680
commit 41ead6611a

@ -195,11 +195,9 @@ static ConfNode *GetConfig(void) {
} }
/** /**
* \brief Initializes the output interface context * \brief Initializes stats context
*
* \todo Support multiple interfaces
*/ */
static void StatsInitOPCtx(void) static void StatsInitCtx(void)
{ {
SCEnter(); SCEnter();
ConfNode *stats = GetConfig(); ConfNode *stats = GetConfig();
@ -237,7 +235,7 @@ static void StatsInitOPCtx(void)
* \brief Releases the resources alloted to the output context of the Perf * \brief Releases the resources alloted to the output context of the Perf
* Counter API * Counter API
*/ */
static void StatsReleaseOPCtx() static void StatsReleaseCtx()
{ {
if (stats_ctx == NULL) { if (stats_ctx == NULL) {
SCLogDebug("Counter module has been disabled"); SCLogDebug("Counter module has been disabled");
@ -461,7 +459,7 @@ static void *StatsWakeupThread(void *arg)
/** /**
* \brief Releases a perf counter. Used internally by * \brief Releases a perf counter. Used internally by
* StatsReleasePerfCounterS() * StatsReleasePerfCounters()
* *
* \param pc Pointer to the StatsCounter to be freed * \param pc Pointer to the StatsCounter to be freed
*/ */
@ -857,7 +855,7 @@ void StatsInit(void)
{ {
BUG_ON(stats_ctx != NULL); BUG_ON(stats_ctx != NULL);
if ( (stats_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) { if ( (stats_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in StatsInitOPCtx. Exiting..."); SCLogError(SC_ERR_FATAL, "Fatal error encountered in StatsInitCtx. Exiting...");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(stats_ctx, 0, sizeof(StatsGlobalContext)); memset(stats_ctx, 0, sizeof(StatsGlobalContext));
@ -865,7 +863,7 @@ void StatsInit(void)
void StatsSetupPostConfig(void) void StatsSetupPostConfig(void)
{ {
StatsInitOPCtx(); StatsInitCtx();
} }
/** /**
@ -1260,7 +1258,7 @@ uint64_t StatsGetLocalCounterValue(ThreadVars *tv, uint16_t id)
*/ */
void StatsReleaseResources() void StatsReleaseResources()
{ {
StatsReleaseOPCtx(); StatsReleaseCtx();
return; return;
} }
@ -1271,7 +1269,7 @@ void StatsReleaseResources()
* \param head Pointer to the head of the list of perf counters that have to * \param head Pointer to the head of the list of perf counters that have to
* be freed * be freed
*/ */
void StatsReleasePerfCounterS(StatsCounter *head) void StatsReleasePerfCounters(StatsCounter *head)
{ {
StatsCounter *pc = NULL; StatsCounter *pc = NULL;
@ -1290,7 +1288,7 @@ void StatsReleasePerfCounterS(StatsCounter *head)
* *
* \param pca Pointer to the StatsPrivateThreadContext * \param pca Pointer to the StatsPrivateThreadContext
*/ */
void StatsReleasePCA(StatsPrivateThreadContext *pca) void StatsReleasePrivateThreadContext(StatsPrivateThreadContext *pca)
{ {
if (pca != NULL) { if (pca != NULL) {
if (pca->head != NULL) { if (pca->head != NULL) {
@ -1345,7 +1343,7 @@ static int StatsTestCounterReg03()
result = RegisterCounter("t1", "c1", &pctx); result = RegisterCounter("t1", "c1", &pctx);
StatsReleasePerfCounterS(pctx.head); StatsReleasePerfCounters(pctx.head);
return result; return result;
} }
@ -1363,7 +1361,7 @@ static int StatsTestCounterReg04()
result = RegisterCounter("t1", "c1", &pctx); result = RegisterCounter("t1", "c1", &pctx);
StatsReleasePerfCounterS(pctx.head); StatsReleasePerfCounters(pctx.head);
return result; return result;
} }
@ -1401,8 +1399,8 @@ static int StatsTestGetCntArray06()
result = (r == 0) ? 1 : 0; result = (r == 0) ? 1 : 0;
StatsReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounters(tv.perf_public_ctx.head);
StatsReleasePCA(&tv.perf_private_ctx); StatsReleasePrivateThreadContext(&tv.perf_private_ctx);
return result; return result;
} }
@ -1428,8 +1426,8 @@ static int StatsTestCntArraySize07()
result = pca->size; result = pca->size;
StatsReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounters(tv.perf_public_ctx.head);
StatsReleasePCA(pca); StatsReleasePrivateThreadContext(pca);
return result; return result;
} }
@ -1453,8 +1451,8 @@ static int StatsTestUpdateCounter08()
result = pca->head[id].value; result = pca->head[id].value;
StatsReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounters(tv.perf_public_ctx.head);
StatsReleasePCA(pca); StatsReleasePrivateThreadContext(pca);
return result; return result;
} }
@ -1482,8 +1480,8 @@ static int StatsTestUpdateCounter09()
result = (pca->head[id1].value == 0) && (pca->head[id2].value == 101); result = (pca->head[id1].value == 0) && (pca->head[id2].value == 101);
StatsReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounters(tv.perf_public_ctx.head);
StatsReleasePCA(pca); StatsReleasePrivateThreadContext(pca);
return result; return result;
} }
@ -1516,8 +1514,8 @@ static int StatsTestUpdateGlobalCounter10()
result &= (100 == tv.perf_public_ctx.head->next->value); result &= (100 == tv.perf_public_ctx.head->next->value);
result &= (101 == tv.perf_public_ctx.head->next->next->value); result &= (101 == tv.perf_public_ctx.head->next->next->value);
StatsReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounters(tv.perf_public_ctx.head);
StatsReleasePCA(pca); StatsReleasePrivateThreadContext(pca);
return result; return result;
} }
@ -1555,8 +1553,8 @@ static int StatsTestCounterValues11()
result &= (16843024 == tv.perf_public_ctx.head->next->next->next->value); result &= (16843024 == tv.perf_public_ctx.head->next->next->next->value);
StatsReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounters(tv.perf_public_ctx.head);
StatsReleasePCA(pca); StatsReleasePrivateThreadContext(pca);
return result; return result;
} }

Loading…
Cancel
Save