counters: remaining s/SCPerf/Stats/g

pull/1508/head
Victor Julien 10 years ago
parent 4362d0a6e9
commit 752f03e7a4

@ -199,7 +199,7 @@ static ConfNode *GetConfig(void) {
* *
* \todo Support multiple interfaces * \todo Support multiple interfaces
*/ */
static void SCPerfInitOPCtx(void) static void StatsInitOPCtx(void)
{ {
SCEnter(); SCEnter();
ConfNode *stats = GetConfig(); ConfNode *stats = GetConfig();
@ -237,7 +237,7 @@ static void SCPerfInitOPCtx(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 SCPerfReleaseOPCtx() static void StatsReleaseOPCtx()
{ {
if (stats_ctx == NULL) { if (stats_ctx == NULL) {
SCLogDebug("Counter module has been disabled"); SCLogDebug("Counter module has been disabled");
@ -280,7 +280,7 @@ static void SCPerfReleaseOPCtx()
* *
* \retval NULL This is the value that is always returned * \retval NULL This is the value that is always returned
*/ */
static void *SCPerfMgmtThread(void *arg) static void *StatsMgmtThread(void *arg)
{ {
/* block usr2. usr2 to be handled by the main thread only */ /* block usr2. usr2 to be handled by the main thread only */
UtilSignalBlock(SIGUSR2); UtilSignalBlock(SIGUSR2);
@ -304,7 +304,7 @@ static void *SCPerfMgmtThread(void *arg)
if (stats_ctx == NULL) { if (stats_ctx == NULL) {
SCLogError(SC_ERR_PERF_STATS_NOT_INIT, "Perf Counter API not init" SCLogError(SC_ERR_PERF_STATS_NOT_INIT, "Perf Counter API not init"
"SCPerfInitCounterApi() has to be called first"); "StatsInitCounterApi() has to be called first");
TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE); TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE);
return NULL; return NULL;
} }
@ -365,7 +365,7 @@ static void *SCPerfMgmtThread(void *arg)
* *
* \retval NULL This is the value that is always returned * \retval NULL This is the value that is always returned
*/ */
static void *SCPerfWakeupThread(void *arg) static void *StatsWakeupThread(void *arg)
{ {
/* block usr2. usr2 to be handled by the main thread only */ /* block usr2. usr2 to be handled by the main thread only */
UtilSignalBlock(SIGUSR2); UtilSignalBlock(SIGUSR2);
@ -391,7 +391,7 @@ static void *SCPerfWakeupThread(void *arg)
if (stats_ctx == NULL) { if (stats_ctx == NULL) {
SCLogError(SC_ERR_PERF_STATS_NOT_INIT, "Perf Counter API not init" SCLogError(SC_ERR_PERF_STATS_NOT_INIT, "Perf Counter API not init"
"SCPerfInitCounterApi() has to be called first"); "StatsInitCounterApi() has to be called first");
TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE); TmThreadsSetFlag(tv_local, THV_CLOSED | THV_RUNNING_DONE);
return NULL; return NULL;
} }
@ -461,11 +461,11 @@ static void *SCPerfWakeupThread(void *arg)
/** /**
* \brief Releases a perf counter. Used internally by * \brief Releases a perf counter. Used internally by
* SCPerfReleasePerfCounterS() * StatsReleasePerfCounterS()
* *
* \param pc Pointer to the SCPerfCounter to be freed * \param pc Pointer to the StatsCounter to be freed
*/ */
static void SCPerfReleaseCounter(SCPerfCounter *pc) static void StatsReleaseCounter(StatsCounter *pc)
{ {
if (pc != NULL) { if (pc != NULL) {
if (pc->cname != NULL) if (pc->cname != NULL)
@ -493,10 +493,10 @@ static uint16_t StatsRegisterQualifiedCounter(char *cname, char *tm_name,
StatsPublicThreadContext *pctx, StatsPublicThreadContext *pctx,
int type_q, uint64_t (*Func)(void)) int type_q, uint64_t (*Func)(void))
{ {
SCPerfCounter **head = &pctx->head; StatsCounter **head = &pctx->head;
SCPerfCounter *temp = NULL; StatsCounter *temp = NULL;
SCPerfCounter *prev = NULL; StatsCounter *prev = NULL;
SCPerfCounter *pc = NULL; StatsCounter *pc = NULL;
if (cname == NULL || pctx == NULL) { if (cname == NULL || pctx == NULL) {
SCLogDebug("Counter name, StatsPublicThreadContext NULL"); SCLogDebug("Counter name, StatsPublicThreadContext NULL");
@ -519,16 +519,16 @@ static uint16_t StatsRegisterQualifiedCounter(char *cname, char *tm_name,
return(temp->id); return(temp->id);
/* if we reach this point we don't have a counter registered by this cname */ /* if we reach this point we don't have a counter registered by this cname */
if ( (pc = SCMalloc(sizeof(SCPerfCounter))) == NULL) if ( (pc = SCMalloc(sizeof(StatsCounter))) == NULL)
return 0; return 0;
memset(pc, 0, sizeof(SCPerfCounter)); memset(pc, 0, sizeof(StatsCounter));
if ( (pc->cname = SCStrdup(cname)) == NULL) { if ( (pc->cname = SCStrdup(cname)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* assign a unique id to this SCPerfCounter. The id is local to this /* assign a unique id to this StatsCounter. The id is local to this
* PerfContext. Please note that the id start from 1, and not 0 */ * PerfContext. Please note that the id start from 1, and not 0 */
pc->id = ++(pctx->curr_id); pc->id = ++(pctx->curr_id);
@ -545,16 +545,16 @@ static uint16_t StatsRegisterQualifiedCounter(char *cname, char *tm_name,
} }
/** /**
* \brief Copies the SCPerfCounter value from the local counter present in the * \brief Copies the StatsCounter value from the local counter present in the
* StatsPrivateThreadContext to its corresponding global counterpart. Used * StatsPrivateThreadContext to its corresponding global counterpart. Used
* internally by SCPerfUpdateCounterArray() * internally by StatsUpdateCounterArray()
* *
* \param pcae Pointer to the StatsPrivateThreadContext which holds the local * \param pcae Pointer to the StatsPrivateThreadContext which holds the local
* versions of the counters * versions of the counters
*/ */
static void SCPerfCopyCounterValue(SCPCAElem *pcae) static void StatsCopyCounterValue(SCPCAElem *pcae)
{ {
SCPerfCounter *pc = pcae->pc; StatsCounter *pc = pcae->pc;
pc->value = pcae->value; pc->value = pcae->value;
pc->updates = pcae->updates; pc->updates = pcae->updates;
@ -574,7 +574,7 @@ static void SCPerfCopyCounterValue(SCPCAElem *pcae)
* \param pc Pointer to the PerfCounter for which the timebased counter has to * \param pc Pointer to the PerfCounter for which the timebased counter has to
* be calculated * be calculated
*/ */
static uint64_t SCPerfOutputCalculateCounterValue(SCPerfCounter *pc) static uint64_t StatsOutputCalculateCounterValue(StatsCounter *pc)
{ {
return pc->value; return pc->value;
} }
@ -585,7 +585,7 @@ static uint64_t SCPerfOutputCalculateCounterValue(SCPerfCounter *pc)
static int StatsOutput(ThreadVars *tv) static int StatsOutput(ThreadVars *tv)
{ {
const StatsThreadStore *sts = NULL; const StatsThreadStore *sts = NULL;
const SCPerfCounter *pc = NULL; const StatsCounter *pc = NULL;
void *td = stats_thread_data; void *td = stats_thread_data;
if (stats_table.nstats == 0) { if (stats_table.nstats == 0) {
@ -756,12 +756,12 @@ static int StatsOutput(ThreadVars *tv)
/** /**
* \brief The file output interface for the Perf Counter api * \brief The file output interface for the Perf Counter api
*/ */
TmEcode SCPerfOutputCounterSocket(json_t *cmd, TmEcode StatsOutputCounterSocket(json_t *cmd,
json_t *answer, void *data) json_t *answer, void *data)
{ {
StatsThreadStore *sts = NULL; StatsThreadStore *sts = NULL;
SCPerfCounter *pc = NULL; StatsCounter *pc = NULL;
SCPerfCounter **pc_heads = NULL; StatsCounter **pc_heads = NULL;
uint64_t ui64_temp = 0; uint64_t ui64_temp = 0;
uint64_t ui64_result = 0; uint64_t ui64_result = 0;
@ -795,13 +795,13 @@ TmEcode SCPerfOutputCounterSocket(json_t *cmd,
json_string("internal error at json object creation")); json_string("internal error at json object creation"));
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
if ((pc_heads = SCMalloc(sts->size * sizeof(SCPerfCounter *))) == NULL) { if ((pc_heads = SCMalloc(sts->size * sizeof(StatsCounter *))) == NULL) {
json_decref(tm_array); json_decref(tm_array);
json_object_set_new(answer, "message", json_object_set_new(answer, "message",
json_string("internal memory error")); json_string("internal memory error"));
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
memset(pc_heads, 0, sts->size * sizeof(SCPerfCounter *)); memset(pc_heads, 0, sts->size * sizeof(StatsCounter *));
for (u = 0; u < sts->size; u++) { for (u = 0; u < sts->size; u++) {
pc_heads[u] = sts->head[u]->head; pc_heads[u] = sts->head[u]->head;
@ -817,7 +817,7 @@ TmEcode SCPerfOutputCounterSocket(json_t *cmd,
pc = pc_heads[0]; pc = pc_heads[0];
for (u = 0; u < sts->size; u++) { for (u = 0; u < sts->size; u++) {
ui64_temp = SCPerfOutputCalculateCounterValue(pc_heads[u]); ui64_temp = StatsOutputCalculateCounterValue(pc_heads[u]);
ui64_result += ui64_temp; ui64_result += ui64_temp;
if (pc_heads[u] != NULL) if (pc_heads[u] != NULL)
@ -857,7 +857,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 SCPerfInitOPCtx. Exiting..."); SCLogError(SC_ERR_FATAL, "Fatal error encountered in StatsInitOPCtx. Exiting...");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
memset(stats_ctx, 0, sizeof(StatsGlobalContext)); memset(stats_ctx, 0, sizeof(StatsGlobalContext));
@ -865,7 +865,7 @@ void StatsInit(void)
void StatsSetupPostConfig(void) void StatsSetupPostConfig(void)
{ {
SCPerfInitOPCtx(); StatsInitOPCtx();
} }
/** /**
@ -875,7 +875,7 @@ void StatsSetupPostConfig(void)
* The threads use the condition variable in the thread vars to control * The threads use the condition variable in the thread vars to control
* their wait loops to make sure the main thread can quickly kill them. * their wait loops to make sure the main thread can quickly kill them.
*/ */
void SCPerfSpawnThreads(void) void StatsSpawnThreads(void)
{ {
SCEnter(); SCEnter();
@ -887,8 +887,8 @@ void SCPerfSpawnThreads(void)
ThreadVars *tv_mgmt = NULL; ThreadVars *tv_mgmt = NULL;
/* spawn the stats wakeup thread */ /* spawn the stats wakeup thread */
tv_wakeup = TmThreadCreateMgmtThread("SCPerfWakeupThread", tv_wakeup = TmThreadCreateMgmtThread("StatsWakeupThread",
SCPerfWakeupThread, 1); StatsWakeupThread, 1);
if (tv_wakeup == NULL) { if (tv_wakeup == NULL) {
SCLogError(SC_ERR_THREAD_CREATE, "TmThreadCreateMgmtThread " SCLogError(SC_ERR_THREAD_CREATE, "TmThreadCreateMgmtThread "
"failed"); "failed");
@ -897,13 +897,13 @@ void SCPerfSpawnThreads(void)
if (TmThreadSpawn(tv_wakeup) != 0) { if (TmThreadSpawn(tv_wakeup) != 0) {
SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for " SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for "
"SCPerfWakeupThread"); "StatsWakeupThread");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* spawn the stats mgmt thread */ /* spawn the stats mgmt thread */
tv_mgmt = TmThreadCreateMgmtThread("SCPerfMgmtThread", tv_mgmt = TmThreadCreateMgmtThread("StatsMgmtThread",
SCPerfMgmtThread, 1); StatsMgmtThread, 1);
if (tv_mgmt == NULL) { if (tv_mgmt == NULL) {
SCLogError(SC_ERR_THREAD_CREATE, SCLogError(SC_ERR_THREAD_CREATE,
"TmThreadCreateMgmtThread failed"); "TmThreadCreateMgmtThread failed");
@ -912,7 +912,7 @@ void SCPerfSpawnThreads(void)
if (TmThreadSpawn(tv_mgmt) != 0) { if (TmThreadSpawn(tv_mgmt) != 0) {
SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for " SCLogError(SC_ERR_THREAD_SPAWN, "TmThreadSpawn failed for "
"SCPerfWakeupThread"); "StatsWakeupThread");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -1086,7 +1086,7 @@ static int StatsThreadRegister(const char *thread_name, StatsPublicThreadContext
CountersIdHashFreeFunc); CountersIdHashFreeFunc);
BUG_ON(stats_ctx->counters_id_hash == NULL); BUG_ON(stats_ctx->counters_id_hash == NULL);
} }
SCPerfCounter *pc = pctx->head; StatsCounter *pc = pctx->head;
while (pc != NULL) { while (pc != NULL) {
CountersIdType t = { 0, pc->cname }, *id = NULL; CountersIdType t = { 0, pc->cname }, *id = NULL;
id = HashTableLookup(stats_ctx->counters_id_hash, &t, sizeof(t)); id = HashTableLookup(stats_ctx->counters_id_hash, &t, sizeof(t));
@ -1135,11 +1135,11 @@ static int StatsThreadRegister(const char *thread_name, StatsPublicThreadContext
* *
* \retval a counter-array in this(s_id-e_id) range for this TM instance * \retval a counter-array in this(s_id-e_id) range for this TM instance
*/ */
static int SCPerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id, static int StatsGetCounterArrayRange(uint16_t s_id, uint16_t e_id,
StatsPublicThreadContext *pctx, StatsPublicThreadContext *pctx,
StatsPrivateThreadContext *pca) StatsPrivateThreadContext *pca)
{ {
SCPerfCounter *pc = NULL; StatsCounter *pc = NULL;
uint32_t i = 0; uint32_t i = 0;
if (pctx == NULL || pca == NULL) { if (pctx == NULL || pca == NULL) {
@ -1188,18 +1188,18 @@ static int SCPerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id,
* \retval pca Pointer to a counter-array for all counter of this tm instance * \retval pca Pointer to a counter-array for all counter of this tm instance
* on success; NULL on failure * on success; NULL on failure
*/ */
static int SCPerfGetAllCountersArray(StatsPublicThreadContext *pctx, StatsPrivateThreadContext *private) static int StatsGetAllCountersArray(StatsPublicThreadContext *pctx, StatsPrivateThreadContext *private)
{ {
if (pctx == NULL || private == NULL) if (pctx == NULL || private == NULL)
return -1; return -1;
return SCPerfGetCounterArrayRange(1, pctx->curr_id, pctx, private); return StatsGetCounterArrayRange(1, pctx->curr_id, pctx, private);
} }
int SCPerfSetupPrivate(ThreadVars *tv) int StatsSetupPrivate(ThreadVars *tv)
{ {
SCPerfGetAllCountersArray(&(tv)->perf_public_ctx, &(tv)->perf_private_ctx); StatsGetAllCountersArray(&(tv)->perf_public_ctx, &(tv)->perf_private_ctx);
StatsThreadRegister(tv->name, &(tv)->perf_public_ctx); StatsThreadRegister(tv->name, &(tv)->perf_public_ctx);
return 0; return 0;
@ -1214,13 +1214,13 @@ int SCPerfSetupPrivate(ThreadVars *tv)
* \retval 0 on success * \retval 0 on success
* \retval -1 on error * \retval -1 on error
*/ */
int SCPerfUpdateCounterArray(StatsPrivateThreadContext *pca, StatsPublicThreadContext *pctx) int StatsUpdateCounterArray(StatsPrivateThreadContext *pca, StatsPublicThreadContext *pctx)
{ {
SCPCAElem *pcae = NULL; SCPCAElem *pcae = NULL;
uint32_t i = 0; uint32_t i = 0;
if (pca == NULL || pctx == NULL) { if (pca == NULL || pctx == NULL) {
SCLogDebug("pca or pctx is NULL inside SCPerfUpdateCounterArray"); SCLogDebug("pca or pctx is NULL inside StatsUpdateCounterArray");
return -1; return -1;
} }
@ -1228,7 +1228,7 @@ int SCPerfUpdateCounterArray(StatsPrivateThreadContext *pca, StatsPublicThreadCo
SCMutexLock(&pctx->m); SCMutexLock(&pctx->m);
for (i = 1; i <= pca->size; i++) { for (i = 1; i <= pca->size; i++) {
SCPerfCopyCounterValue(&pcae[i]); StatsCopyCounterValue(&pcae[i]);
} }
SCMutexUnlock(&pctx->m); SCMutexUnlock(&pctx->m);
@ -1246,7 +1246,7 @@ int SCPerfUpdateCounterArray(StatsPrivateThreadContext *pca, StatsPublicThreadCo
* \retval 0 on success. * \retval 0 on success.
* \retval -1 on error. * \retval -1 on error.
*/ */
uint64_t SCPerfGetLocalCounterValue(ThreadVars *tv, uint16_t id) uint64_t StatsGetLocalCounterValue(ThreadVars *tv, uint16_t id)
{ {
StatsPrivateThreadContext *pca = &tv->perf_private_ctx; StatsPrivateThreadContext *pca = &tv->perf_private_ctx;
#ifdef DEBUG #ifdef DEBUG
@ -1258,9 +1258,9 @@ uint64_t SCPerfGetLocalCounterValue(ThreadVars *tv, uint16_t id)
/** /**
* \brief Releases the resources alloted by the Perf Counter API * \brief Releases the resources alloted by the Perf Counter API
*/ */
void SCPerfReleaseResources() void StatsReleaseResources()
{ {
SCPerfReleaseOPCtx(); StatsReleaseOPCtx();
return; return;
} }
@ -1271,14 +1271,14 @@ void SCPerfReleaseResources()
* \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 SCPerfReleasePerfCounterS(SCPerfCounter *head) void StatsReleasePerfCounterS(StatsCounter *head)
{ {
SCPerfCounter *pc = NULL; StatsCounter *pc = NULL;
while (head != NULL) { while (head != NULL) {
pc = head; pc = head;
head = head->next; head = head->next;
SCPerfReleaseCounter(pc); StatsReleaseCounter(pc);
} }
return; return;
@ -1290,7 +1290,7 @@ void SCPerfReleasePerfCounterS(SCPerfCounter *head)
* *
* \param pca Pointer to the StatsPrivateThreadContext * \param pca Pointer to the StatsPrivateThreadContext
*/ */
void SCPerfReleasePCA(StatsPrivateThreadContext *pca) void StatsReleasePCA(StatsPrivateThreadContext *pca)
{ {
if (pca != NULL) { if (pca != NULL) {
if (pca->head != NULL) { if (pca->head != NULL) {
@ -1327,7 +1327,7 @@ static uint16_t RegisterCounter(char *cname, char *tm_name,
return id; return id;
} }
static int SCPerfTestCounterReg02() static int StatsTestCounterReg02()
{ {
StatsPublicThreadContext pctx; StatsPublicThreadContext pctx;
@ -1336,7 +1336,7 @@ static int SCPerfTestCounterReg02()
return RegisterCounter(NULL, NULL, &pctx); return RegisterCounter(NULL, NULL, &pctx);
} }
static int SCPerfTestCounterReg03() static int StatsTestCounterReg03()
{ {
StatsPublicThreadContext pctx; StatsPublicThreadContext pctx;
int result; int result;
@ -1345,12 +1345,12 @@ static int SCPerfTestCounterReg03()
result = RegisterCounter("t1", "c1", &pctx); result = RegisterCounter("t1", "c1", &pctx);
SCPerfReleasePerfCounterS(pctx.head); StatsReleasePerfCounterS(pctx.head);
return result; return result;
} }
static int SCPerfTestCounterReg04() static int StatsTestCounterReg04()
{ {
StatsPublicThreadContext pctx; StatsPublicThreadContext pctx;
int result; int result;
@ -1363,12 +1363,12 @@ static int SCPerfTestCounterReg04()
result = RegisterCounter("t1", "c1", &pctx); result = RegisterCounter("t1", "c1", &pctx);
SCPerfReleasePerfCounterS(pctx.head); StatsReleasePerfCounterS(pctx.head);
return result; return result;
} }
static int SCPerfTestGetCntArray05() static int StatsTestGetCntArray05()
{ {
ThreadVars tv; ThreadVars tv;
int id; int id;
@ -1381,11 +1381,11 @@ static int SCPerfTestGetCntArray05()
return 0; return 0;
} }
int r = SCPerfGetAllCountersArray(NULL, &tv.perf_private_ctx); int r = StatsGetAllCountersArray(NULL, &tv.perf_private_ctx);
return (r == -1) ? 1 : 0; return (r == -1) ? 1 : 0;
} }
static int SCPerfTestGetCntArray06() static int StatsTestGetCntArray06()
{ {
ThreadVars tv; ThreadVars tv;
int id; int id;
@ -1397,17 +1397,17 @@ static int SCPerfTestGetCntArray06()
if (id != 1) if (id != 1)
return 0; return 0;
int r = SCPerfGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); int r = StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
result = (r == 0) ? 1 : 0; result = (r == 0) ? 1 : 0;
SCPerfReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounterS(tv.perf_public_ctx.head);
SCPerfReleasePCA(&tv.perf_private_ctx); StatsReleasePCA(&tv.perf_private_ctx);
return result; return result;
} }
static int SCPerfTestCntArraySize07() static int StatsTestCntArraySize07()
{ {
ThreadVars tv; ThreadVars tv;
StatsPrivateThreadContext *pca = NULL; StatsPrivateThreadContext *pca = NULL;
@ -1420,7 +1420,7 @@ static int SCPerfTestCntArraySize07()
RegisterCounter("t1", "c1", &tv.perf_public_ctx); RegisterCounter("t1", "c1", &tv.perf_public_ctx);
RegisterCounter("t2", "c2", &tv.perf_public_ctx); RegisterCounter("t2", "c2", &tv.perf_public_ctx);
SCPerfGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
pca = &tv.perf_private_ctx; pca = &tv.perf_private_ctx;
StatsIncr(&tv, 1); StatsIncr(&tv, 1);
@ -1428,13 +1428,13 @@ static int SCPerfTestCntArraySize07()
result = pca->size; result = pca->size;
SCPerfReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounterS(tv.perf_public_ctx.head);
SCPerfReleasePCA(pca); StatsReleasePCA(pca);
return result; return result;
} }
static int SCPerfTestUpdateCounter08() static int StatsTestUpdateCounter08()
{ {
ThreadVars tv; ThreadVars tv;
StatsPrivateThreadContext *pca = NULL; StatsPrivateThreadContext *pca = NULL;
@ -1445,7 +1445,7 @@ static int SCPerfTestUpdateCounter08()
id = RegisterCounter("t1", "c1", &tv.perf_public_ctx); id = RegisterCounter("t1", "c1", &tv.perf_public_ctx);
SCPerfGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
pca = &tv.perf_private_ctx; pca = &tv.perf_private_ctx;
StatsIncr(&tv, id); StatsIncr(&tv, id);
@ -1453,13 +1453,13 @@ static int SCPerfTestUpdateCounter08()
result = pca->head[id].value; result = pca->head[id].value;
SCPerfReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounterS(tv.perf_public_ctx.head);
SCPerfReleasePCA(pca); StatsReleasePCA(pca);
return result; return result;
} }
static int SCPerfTestUpdateCounter09() static int StatsTestUpdateCounter09()
{ {
ThreadVars tv; ThreadVars tv;
StatsPrivateThreadContext *pca = NULL; StatsPrivateThreadContext *pca = NULL;
@ -1474,7 +1474,7 @@ static int SCPerfTestUpdateCounter09()
RegisterCounter("t4", "c4", &tv.perf_public_ctx); RegisterCounter("t4", "c4", &tv.perf_public_ctx);
id2 = RegisterCounter("t5", "c5", &tv.perf_public_ctx); id2 = RegisterCounter("t5", "c5", &tv.perf_public_ctx);
SCPerfGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
pca = &tv.perf_private_ctx; pca = &tv.perf_private_ctx;
StatsIncr(&tv, id2); StatsIncr(&tv, id2);
@ -1482,13 +1482,13 @@ static int SCPerfTestUpdateCounter09()
result = (pca->head[id1].value == 0) && (pca->head[id2].value == 101); result = (pca->head[id1].value == 0) && (pca->head[id2].value == 101);
SCPerfReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounterS(tv.perf_public_ctx.head);
SCPerfReleasePCA(pca); StatsReleasePCA(pca);
return result; return result;
} }
static int SCPerfTestUpdateGlobalCounter10() static int StatsTestUpdateGlobalCounter10()
{ {
ThreadVars tv; ThreadVars tv;
StatsPrivateThreadContext *pca = NULL; StatsPrivateThreadContext *pca = NULL;
@ -1502,7 +1502,7 @@ static int SCPerfTestUpdateGlobalCounter10()
id2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx); id2 = RegisterCounter("t2", "c2", &tv.perf_public_ctx);
id3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx); id3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx);
SCPerfGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
pca = &tv.perf_private_ctx; pca = &tv.perf_private_ctx;
StatsIncr(&tv, id1); StatsIncr(&tv, id1);
@ -1510,19 +1510,19 @@ static int SCPerfTestUpdateGlobalCounter10()
StatsIncr(&tv, id3); StatsIncr(&tv, id3);
StatsAddUI64(&tv, id3, 100); StatsAddUI64(&tv, id3, 100);
SCPerfUpdateCounterArray(pca, &tv.perf_public_ctx); StatsUpdateCounterArray(pca, &tv.perf_public_ctx);
result = (1 == tv.perf_public_ctx.head->value); result = (1 == tv.perf_public_ctx.head->value);
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);
SCPerfReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounterS(tv.perf_public_ctx.head);
SCPerfReleasePCA(pca); StatsReleasePCA(pca);
return result; return result;
} }
static int SCPerfTestCounterValues11() static int StatsTestCounterValues11()
{ {
ThreadVars tv; ThreadVars tv;
StatsPrivateThreadContext *pca = NULL; StatsPrivateThreadContext *pca = NULL;
@ -1537,7 +1537,7 @@ static int SCPerfTestCounterValues11()
id3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx); id3 = RegisterCounter("t3", "c3", &tv.perf_public_ctx);
id4 = RegisterCounter("t4", "c4", &tv.perf_public_ctx); id4 = RegisterCounter("t4", "c4", &tv.perf_public_ctx);
SCPerfGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx); StatsGetAllCountersArray(&tv.perf_public_ctx, &tv.perf_private_ctx);
pca = &tv.perf_private_ctx; pca = &tv.perf_private_ctx;
StatsIncr(&tv, id1); StatsIncr(&tv, id1);
@ -1545,7 +1545,7 @@ static int SCPerfTestCounterValues11()
StatsAddUI64(&tv, id3, 257); StatsAddUI64(&tv, id3, 257);
StatsAddUI64(&tv, id4, 16843024); StatsAddUI64(&tv, id4, 16843024);
SCPerfUpdateCounterArray(pca, &tv.perf_public_ctx); StatsUpdateCounterArray(pca, &tv.perf_public_ctx);
result &= (1 == tv.perf_public_ctx.head->value); result &= (1 == tv.perf_public_ctx.head->value);
@ -1555,27 +1555,27 @@ static int SCPerfTestCounterValues11()
result &= (16843024 == tv.perf_public_ctx.head->next->next->next->value); result &= (16843024 == tv.perf_public_ctx.head->next->next->next->value);
SCPerfReleasePerfCounterS(tv.perf_public_ctx.head); StatsReleasePerfCounterS(tv.perf_public_ctx.head);
SCPerfReleasePCA(pca); StatsReleasePCA(pca);
return result; return result;
} }
#endif #endif
void SCPerfRegisterTests() void StatsRegisterTests()
{ {
#ifdef UNITTESTS #ifdef UNITTESTS
UtRegisterTest("SCPerfTestCounterReg02", SCPerfTestCounterReg02, 0); UtRegisterTest("StatsTestCounterReg02", StatsTestCounterReg02, 0);
UtRegisterTest("SCPerfTestCounterReg03", SCPerfTestCounterReg03, 1); UtRegisterTest("StatsTestCounterReg03", StatsTestCounterReg03, 1);
UtRegisterTest("SCPerfTestCounterReg04", SCPerfTestCounterReg04, 1); UtRegisterTest("StatsTestCounterReg04", StatsTestCounterReg04, 1);
UtRegisterTest("SCPerfTestGetCntArray05", SCPerfTestGetCntArray05, 1); UtRegisterTest("StatsTestGetCntArray05", StatsTestGetCntArray05, 1);
UtRegisterTest("SCPerfTestGetCntArray06", SCPerfTestGetCntArray06, 1); UtRegisterTest("StatsTestGetCntArray06", StatsTestGetCntArray06, 1);
UtRegisterTest("SCPerfTestCntArraySize07", SCPerfTestCntArraySize07, 2); UtRegisterTest("StatsTestCntArraySize07", StatsTestCntArraySize07, 2);
UtRegisterTest("SCPerfTestUpdateCounter08", SCPerfTestUpdateCounter08, 101); UtRegisterTest("StatsTestUpdateCounter08", StatsTestUpdateCounter08, 101);
UtRegisterTest("SCPerfTestUpdateCounter09", SCPerfTestUpdateCounter09, 1); UtRegisterTest("StatsTestUpdateCounter09", StatsTestUpdateCounter09, 1);
UtRegisterTest("SCPerfTestUpdateGlobalCounter10", UtRegisterTest("StatsTestUpdateGlobalCounter10",
SCPerfTestUpdateGlobalCounter10, 1); StatsTestUpdateGlobalCounter10, 1);
UtRegisterTest("SCPerfTestCounterValues11", SCPerfTestCounterValues11, 1); UtRegisterTest("StatsTestCounterValues11", StatsTestCounterValues11, 1);
#endif #endif
} }

@ -31,7 +31,7 @@ struct ThreadVars_;
/** /**
* \brief Container to hold the counter variable * \brief Container to hold the counter variable
*/ */
typedef struct SCPerfCounter_ { typedef struct StatsCounter_ {
int type; int type;
/* local id for this counter in this tm */ /* local id for this counter in this tm */
@ -52,8 +52,8 @@ typedef struct SCPerfCounter_ {
char *cname; char *cname;
/* the next perfcounter for this tv's tm instance */ /* the next perfcounter for this tv's tm instance */
struct SCPerfCounter_ *next; struct StatsCounter_ *next;
} SCPerfCounter; } StatsCounter;
/** /**
* \brief Holds the Perf Context for a ThreadVars instance * \brief Holds the Perf Context for a ThreadVars instance
@ -63,7 +63,7 @@ typedef struct StatsPublicThreadContext_ {
uint32_t perf_flag; uint32_t perf_flag;
/* pointer to the head of a list of counters assigned under this context */ /* pointer to the head of a list of counters assigned under this context */
SCPerfCounter *head; StatsCounter *head;
/* holds the total no of counters already assigned for this perf context */ /* holds the total no of counters already assigned for this perf context */
uint16_t curr_id; uint16_t curr_id;
@ -77,7 +77,7 @@ typedef struct StatsPublicThreadContext_ {
*/ */
typedef struct SCPCAElem_ { typedef struct SCPCAElem_ {
/* pointer to the PerfCounter that corresponds to this PCAElem */ /* pointer to the PerfCounter that corresponds to this PCAElem */
SCPerfCounter *pc; StatsCounter *pc;
/* counter id of the above counter(pc) */ /* counter id of the above counter(pc) */
uint16_t id; uint16_t id;
@ -105,8 +105,8 @@ typedef struct StatsPrivateThreadContext_ {
/* the initialization functions */ /* the initialization functions */
void StatsInit(void); void StatsInit(void);
void StatsSetupPostConfig(void); void StatsSetupPostConfig(void);
void SCPerfSpawnThreads(void); void StatsSpawnThreads(void);
void SCPerfRegisterTests(void); void StatsRegisterTests(void);
/* counter registration functions */ /* counter registration functions */
uint16_t StatsRegisterCounter(char *, struct ThreadVars_ *); uint16_t StatsRegisterCounter(char *, struct ThreadVars_ *);
@ -115,33 +115,33 @@ uint16_t StatsRegisterMaxCounter(char *, struct ThreadVars_ *);
uint16_t StatsRegisterGlobalCounter(char *cname, uint64_t (*Func)(void)); uint16_t StatsRegisterGlobalCounter(char *cname, uint64_t (*Func)(void));
/* utility functions */ /* utility functions */
int SCPerfUpdateCounterArray(StatsPrivateThreadContext *, StatsPublicThreadContext *); int StatsUpdateCounterArray(StatsPrivateThreadContext *, StatsPublicThreadContext *);
uint64_t SCPerfGetLocalCounterValue(struct ThreadVars_ *, uint16_t); uint64_t StatsGetLocalCounterValue(struct ThreadVars_ *, uint16_t);
int SCPerfSetupPrivate(struct ThreadVars_ *); int StatsSetupPrivate(struct ThreadVars_ *);
/* functions used to free the resources alloted by the Perf counter API */ /* functions used to free the resources alloted by the Perf counter API */
void SCPerfReleaseResources(void); void StatsReleaseResources(void);
void SCPerfReleasePCA(StatsPrivateThreadContext *); void StatsReleasePCA(StatsPrivateThreadContext *);
/* functions used to update local counter values */ /* functions used to update local counter values */
void StatsAddUI64(struct ThreadVars_ *, uint16_t, uint64_t); void StatsAddUI64(struct ThreadVars_ *, uint16_t, uint64_t);
void StatsSetUI64(struct ThreadVars_ *, uint16_t, uint64_t); void StatsSetUI64(struct ThreadVars_ *, uint16_t, uint64_t);
void StatsIncr(struct ThreadVars_ *, uint16_t); void StatsIncr(struct ThreadVars_ *, uint16_t);
#define SCPerfSyncCounters(tv) \ #define StatsSyncCounters(tv) \
SCPerfUpdateCounterArray(&(tv)->perf_private_ctx, &(tv)->perf_public_ctx); \ StatsUpdateCounterArray(&(tv)->perf_private_ctx, &(tv)->perf_public_ctx); \
#define SCPerfSyncCountersIfSignalled(tv) \ #define StatsSyncCountersIfSignalled(tv) \
do { \ do { \
if ((tv)->perf_public_ctx.perf_flag == 1) { \ if ((tv)->perf_public_ctx.perf_flag == 1) { \
SCPerfUpdateCounterArray(&(tv)->perf_private_ctx, \ StatsUpdateCounterArray(&(tv)->perf_private_ctx, \
&(tv)->perf_public_ctx); \ &(tv)->perf_public_ctx); \
} \ } \
} while (0) } while (0)
#ifdef BUILD_UNIX_SOCKET #ifdef BUILD_UNIX_SOCKET
#include <jansson.h> #include <jansson.h>
TmEcode SCPerfOutputCounterSocket(json_t *cmd, TmEcode StatsOutputCounterSocket(json_t *cmd,
json_t *answer, void *data); json_t *answer, void *data);
#endif #endif

@ -11263,24 +11263,24 @@ static int SigTestDetectAlertCounter(void)
DetectEngineThreadCtxInit(&tv, de_ctx, (void *)&det_ctx); DetectEngineThreadCtxInit(&tv, de_ctx, (void *)&det_ctx);
/* init counters */ /* init counters */
SCPerfSetupPrivate(&tv); StatsSetupPrivate(&tv);
p = UTHBuildPacket((uint8_t *)"boo", strlen("boo"), IPPROTO_TCP); p = UTHBuildPacket((uint8_t *)"boo", strlen("boo"), IPPROTO_TCP);
Detect(&tv, p, det_ctx, NULL, NULL); Detect(&tv, p, det_ctx, NULL, NULL);
result = (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 1); result = (StatsGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 1);
Detect(&tv, p, det_ctx, NULL, NULL); Detect(&tv, p, det_ctx, NULL, NULL);
result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2); result &= (StatsGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2);
UTHFreePackets(&p, 1); UTHFreePackets(&p, 1);
p = UTHBuildPacket((uint8_t *)"roo", strlen("roo"), IPPROTO_TCP); p = UTHBuildPacket((uint8_t *)"roo", strlen("roo"), IPPROTO_TCP);
Detect(&tv, p, det_ctx, NULL, NULL); Detect(&tv, p, det_ctx, NULL, NULL);
result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2); result &= (StatsGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 2);
UTHFreePackets(&p, 1); UTHFreePackets(&p, 1);
p = UTHBuildPacket((uint8_t *)"laboosa", strlen("laboosa"), IPPROTO_TCP); p = UTHBuildPacket((uint8_t *)"laboosa", strlen("laboosa"), IPPROTO_TCP);
Detect(&tv, p, det_ctx, NULL, NULL); Detect(&tv, p, det_ctx, NULL, NULL);
result &= (SCPerfGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 3); result &= (StatsGetLocalCounterValue(&tv, det_ctx->counter_alerts) == 3);
UTHFreePackets(&p, 1); UTHFreePackets(&p, 1);
end: end:

@ -670,7 +670,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
} }
if (TmThreadsCheckFlag(th_v, THV_KILL)) { if (TmThreadsCheckFlag(th_v, THV_KILL)) {
SCPerfSyncCounters(th_v); StatsSyncCounters(th_v);
break; break;
} }
@ -683,7 +683,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
SCLogDebug("woke up... %s", SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY ? "emergency":""); SCLogDebug("woke up... %s", SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY ? "emergency":"");
SCPerfSyncCountersIfSignalled(th_v); StatsSyncCountersIfSignalled(th_v);
} }
FlowHashDebugDeinit(); FlowHashDebugDeinit();
@ -822,7 +822,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data)
SCLogDebug("%u flows to recycle", len); SCLogDebug("%u flows to recycle", len);
if (TmThreadsCheckFlag(th_v, THV_KILL)) { if (TmThreadsCheckFlag(th_v, THV_KILL)) {
SCPerfSyncCounters(th_v); StatsSyncCounters(th_v);
break; break;
} }
@ -835,7 +835,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data)
SCLogDebug("woke up..."); SCLogDebug("woke up...");
SCPerfSyncCountersIfSignalled(th_v); StatsSyncCountersIfSignalled(th_v);
} }
SCLogInfo("%"PRIu64" flows processed", recycled_cnt); SCLogInfo("%"PRIu64" flows processed", recycled_cnt);

@ -203,7 +203,7 @@ void RunUnittests(int list_unittests, char *regex_arg)
FlowBitRegisterTests(); FlowBitRegisterTests();
HostBitRegisterTests(); HostBitRegisterTests();
IPPairBitRegisterTests(); IPPairBitRegisterTests();
SCPerfRegisterTests(); StatsRegisterTests();
DecodePPPRegisterTests(); DecodePPPRegisterTests();
DecodeVLANRegisterTests(); DecodeVLANRegisterTests();
HTPParserRegisterTests(); HTPParserRegisterTests();

@ -306,7 +306,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data)
/* mgt and ppt threads killed, we can run non thread-safe /* mgt and ppt threads killed, we can run non thread-safe
* shutdown functions */ * shutdown functions */
SCPerfReleaseResources(); StatsReleaseResources();
RunModeShutDown(); RunModeShutDown();
FlowShutdown(); FlowShutdown();
IPPairShutdown(); IPPairShutdown();
@ -359,7 +359,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data)
RunModeDispatch(RUNMODE_PCAP_FILE, NULL); RunModeDispatch(RUNMODE_PCAP_FILE, NULL);
FlowManagerThreadSpawn(); FlowManagerThreadSpawn();
FlowRecyclerThreadSpawn(); FlowRecyclerThreadSpawn();
SCPerfSpawnThreads(); StatsSpawnThreads();
/* Un-pause all the paused threads */ /* Un-pause all the paused threads */
TmThreadContinueThreads(); TmThreadContinueThreads();
} }

@ -1247,11 +1247,11 @@ TmEcode ReceiveAFPLoop(ThreadVars *tv, void *data, void *slot)
AFPSwitchState(ptv, AFP_STATE_DOWN); AFPSwitchState(ptv, AFP_STATE_DOWN);
continue; continue;
} }
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
AFPDumpCounters(ptv); AFPDumpCounters(ptv);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
} }
@ -1801,8 +1801,8 @@ void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data)
AFPDumpCounters(ptv); AFPDumpCounters(ptv);
SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "", SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "",
tv->name, tv->name,
SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_packets), StatsGetLocalCounterValue(tv, ptv->capture_kernel_packets),
SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_drops)); StatsGetLocalCounterValue(tv, ptv->capture_kernel_drops));
#endif #endif
SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes); SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);

@ -379,7 +379,7 @@ ReceiveErfDagLoop(ThreadVars *tv, void *data, void *slot)
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
SCLogDebug("Read %d records from stream: %d, DAG: %s", SCLogDebug("Read %d records from stream: %d, DAG: %s",
pkts_read, dtv->dagstream, dtv->dagname); pkts_read, dtv->dagstream, dtv->dagname);
@ -558,16 +558,16 @@ ReceiveErfDagThreadExitStats(ThreadVars *tv, void *data)
ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data; ErfDagThreadVars *ewtn = (ErfDagThreadVars *)data;
(void)SC_ATOMIC_SET(ewtn->livedev->pkts, (void)SC_ATOMIC_SET(ewtn->livedev->pkts,
SCPerfGetLocalCounterValue(tv, ewtn->packets)); StatsGetLocalCounterValue(tv, ewtn->packets));
(void)SC_ATOMIC_SET(ewtn->livedev->drop, (void)SC_ATOMIC_SET(ewtn->livedev->drop,
SCPerfGetLocalCounterValue(tv, ewtn->drops)); StatsGetLocalCounterValue(tv, ewtn->drops));
SCLogInfo("Stream: %d; Bytes: %"PRIu64"; Packets: %"PRIu64 SCLogInfo("Stream: %d; Bytes: %"PRIu64"; Packets: %"PRIu64
"; Drops: %"PRIu64, "; Drops: %"PRIu64,
ewtn->dagstream, ewtn->dagstream,
ewtn->bytes, ewtn->bytes,
SCPerfGetLocalCounterValue(tv, ewtn->packets), StatsGetLocalCounterValue(tv, ewtn->packets),
SCPerfGetLocalCounterValue(tv, ewtn->drops)); StatsGetLocalCounterValue(tv, ewtn->drops));
} }
/** /**

@ -307,7 +307,7 @@ TmEcode ReceiveIPFWLoop(ThreadVars *tv, void *data, void *slot)
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);

@ -414,7 +414,7 @@ TmEcode ReceiveMpipeLoop(ThreadVars *tv, void *data, void *slot)
} }
if (update_counter-- <= 0) { if (update_counter-- <= 0) {
/* Only periodically update and check for termination. */ /* Only periodically update and check for termination. */
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
update_counter = 10000; update_counter = 10000;
if (suricata_ctl_flags != 0) { if (suricata_ctl_flags != 0) {

@ -294,7 +294,7 @@ TmEcode NapatechStreamLoop(ThreadVars *tv, void *data, void *slot)
} }
NT_NetRxRelease(ntv->rx_stream, packet_buffer); NT_NetRxRelease(ntv->rx_stream, packet_buffer);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);

@ -826,11 +826,11 @@ static TmEcode ReceiveNetmapLoop(ThreadVars *tv, void *data, void *slot)
} }
NetmapDumpCounters(ntv); NetmapDumpCounters(ntv);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
SCFree(fds); SCFree(fds);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
} }
@ -847,8 +847,8 @@ static void ReceiveNetmapThreadExitStats(ThreadVars *tv, void *data)
NetmapDumpCounters(ntv); NetmapDumpCounters(ntv);
SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 ", bytes %" PRIu64 "", SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 ", bytes %" PRIu64 "",
tv->name, tv->name,
SCPerfGetLocalCounterValue(tv, ntv->capture_kernel_packets), StatsGetLocalCounterValue(tv, ntv->capture_kernel_packets),
SCPerfGetLocalCounterValue(tv, ntv->capture_kernel_drops), StatsGetLocalCounterValue(tv, ntv->capture_kernel_drops),
ntv->bytes); ntv->bytes);
} }

@ -461,7 +461,7 @@ TmEcode ReceiveNFLOGLoop(ThreadVars *tv, void *data, void *slot)
SCLogWarning(SC_ERR_NFLOG_HANDLE_PKT, SCLogWarning(SC_ERR_NFLOG_HANDLE_PKT,
"nflog_handle_packet error %" PRId32 "", ret); "nflog_handle_packet error %" PRId32 "", ret);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);

@ -1003,7 +1003,7 @@ TmEcode ReceiveNFQLoop(ThreadVars *tv, void *data, void *slot)
} }
NFQRecvPkt(nq, ntv); NFQRecvPkt(nq, ntv);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
} }

@ -248,7 +248,7 @@ TmEcode ReceivePcapFileLoop(ThreadVars *tv, void *data, void *slot)
SCReturnInt(TM_ECODE_DONE); SCReturnInt(TM_ECODE_DONE);
} }
} }
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);

@ -340,11 +340,11 @@ TmEcode ReceivePcapLoop(ThreadVars *tv, void *data, void *slot)
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
PcapDumpCounters(ptv); PcapDumpCounters(ptv);
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
} }

@ -198,8 +198,8 @@ static inline void PfringDumpCounters(PfringThreadVars *ptv)
* So to get the number of packet on the interface we can add * So to get the number of packet on the interface we can add
* the newly seen packets and drops for this thread and add it * the newly seen packets and drops for this thread and add it
* to the interface counter */ * to the interface counter */
uint64_t th_pkts = SCPerfGetLocalCounterValue(ptv->tv, ptv->capture_kernel_packets); uint64_t th_pkts = StatsGetLocalCounterValue(ptv->tv, ptv->capture_kernel_packets);
uint64_t th_drops = SCPerfGetLocalCounterValue(ptv->tv, ptv->capture_kernel_drops); uint64_t th_drops = StatsGetLocalCounterValue(ptv->tv, ptv->capture_kernel_drops);
SC_ATOMIC_ADD(ptv->livedev->pkts, pfring_s.recv - th_pkts); SC_ATOMIC_ADD(ptv->livedev->pkts, pfring_s.recv - th_pkts);
SC_ATOMIC_ADD(ptv->livedev->drop, pfring_s.drop - th_drops); SC_ATOMIC_ADD(ptv->livedev->drop, pfring_s.drop - th_drops);
StatsSetUI64(ptv->tv, ptv->capture_kernel_packets, pfring_s.recv); StatsSetUI64(ptv->tv, ptv->capture_kernel_packets, pfring_s.recv);
@ -360,7 +360,7 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
TmqhOutputPacketpool(ptv->tv, p); TmqhOutputPacketpool(ptv->tv, p);
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
} }
return TM_ECODE_OK; return TM_ECODE_OK;
@ -548,8 +548,8 @@ void ReceivePfringThreadExitStats(ThreadVars *tv, void *data)
PfringDumpCounters(ptv); PfringDumpCounters(ptv);
SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "", SCLogInfo("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 "",
tv->name, tv->name,
SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_packets), StatsGetLocalCounterValue(tv, ptv->capture_kernel_packets),
SCPerfGetLocalCounterValue(tv, ptv->capture_kernel_drops)); StatsGetLocalCounterValue(tv, ptv->capture_kernel_drops));
SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes); SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
} }

@ -2337,7 +2337,7 @@ int main(int argc, char **argv)
/* Spawn the flow manager thread */ /* Spawn the flow manager thread */
FlowManagerThreadSpawn(); FlowManagerThreadSpawn();
FlowRecyclerThreadSpawn(); FlowRecyclerThreadSpawn();
SCPerfSpawnThreads(); StatsSpawnThreads();
} }
#ifdef __SC_CUDA_SUPPORT__ #ifdef __SC_CUDA_SUPPORT__
@ -2452,7 +2452,7 @@ int main(int argc, char **argv)
* the other threads are gone. */ * the other threads are gone. */
PacketPoolDestroy(); PacketPoolDestroy();
SCPerfReleaseResources(); StatsReleaseResources();
IPPairShutdown(); IPPairShutdown();
FlowShutdown(); FlowShutdown();
StreamTcpFreeConfig(STREAM_VERBOSE); StreamTcpFreeConfig(STREAM_VERBOSE);

@ -322,7 +322,7 @@ void *TmThreadsSlotPktAcqLoop(void *td)
} }
} }
SCPerfSetupPrivate(tv); StatsSetupPrivate(tv);
TmThreadsSetFlag(tv, THV_INIT_DONE); TmThreadsSetFlag(tv, THV_INIT_DONE);
@ -343,7 +343,7 @@ void *TmThreadsSlotPktAcqLoop(void *td)
run = 0; run = 0;
} }
} }
SCPerfSyncCounters(tv); StatsSyncCounters(tv);
TmThreadsSetFlag(tv, THV_FLOW_LOOP); TmThreadsSetFlag(tv, THV_FLOW_LOOP);
@ -453,7 +453,7 @@ void *TmThreadsSlotVar(void *td)
} }
} }
SCPerfSetupPrivate(tv); StatsSetupPrivate(tv);
TmThreadsSetFlag(tv, THV_INIT_DONE); TmThreadsSetFlag(tv, THV_INIT_DONE);
@ -517,7 +517,7 @@ void *TmThreadsSlotVar(void *td)
run = 0; run = 0;
} }
} /* while (run) */ } /* while (run) */
SCPerfSyncCounters(tv); StatsSyncCounters(tv);
TmThreadsSetFlag(tv, THV_RUNNING_DONE); TmThreadsSetFlag(tv, THV_RUNNING_DONE);
TmThreadWaitForFlag(tv, THV_DEINIT); TmThreadWaitForFlag(tv, THV_DEINIT);
@ -593,7 +593,7 @@ static void *TmThreadsManagement(void *td)
memset(&s->slot_pre_pq, 0, sizeof(PacketQueue)); memset(&s->slot_pre_pq, 0, sizeof(PacketQueue));
memset(&s->slot_post_pq, 0, sizeof(PacketQueue)); memset(&s->slot_post_pq, 0, sizeof(PacketQueue));
SCPerfSetupPrivate(tv); StatsSetupPrivate(tv);
TmThreadsSetFlag(tv, THV_INIT_DONE); TmThreadsSetFlag(tv, THV_INIT_DONE);
@ -604,7 +604,7 @@ static void *TmThreadsManagement(void *td)
} }
if (TmThreadsCheckFlag(tv, THV_KILL)) { if (TmThreadsCheckFlag(tv, THV_KILL)) {
SCPerfSyncCounters(tv); StatsSyncCounters(tv);
} }
TmThreadsSetFlag(tv, THV_RUNNING_DONE); TmThreadsSetFlag(tv, THV_RUNNING_DONE);

@ -85,7 +85,7 @@ Packet *TmqhInputFlow(ThreadVars *tv)
{ {
PacketQueue *q = &trans_q[tv->inq->id]; PacketQueue *q = &trans_q[tv->inq->id];
SCPerfSyncCountersIfSignalled(tv); StatsSyncCountersIfSignalled(tv);
SCMutexLock(&q->mutex_q); SCMutexLock(&q->mutex_q);
if (q->len == 0) { if (q->len == 0) {

@ -104,7 +104,7 @@ Packet *TmqhInputRingBufferMrSw(ThreadVars *t)
Packet *p = (Packet *)RingBufferMrSw8Get(rb); Packet *p = (Packet *)RingBufferMrSw8Get(rb);
SCPerfSyncCountersIfSignalled(t); StatsSyncCountersIfSignalled(t);
return p; return p;
} }
@ -121,7 +121,7 @@ Packet *TmqhInputRingBufferSrSw(ThreadVars *t)
Packet *p = (Packet *)RingBufferSrSw8Get(rb); Packet *p = (Packet *)RingBufferSrSw8Get(rb);
SCPerfSyncCountersIfSignalled(t); StatsSyncCountersIfSignalled(t);
return p; return p;
} }
@ -138,7 +138,7 @@ Packet *TmqhInputRingBufferSrMw(ThreadVars *t)
Packet *p = (Packet *)RingBufferSrMw8Get(rb); Packet *p = (Packet *)RingBufferSrMw8Get(rb);
SCPerfSyncCountersIfSignalled(t); StatsSyncCountersIfSignalled(t);
return p; return p;
} }

@ -47,7 +47,7 @@ Packet *TmqhInputSimple(ThreadVars *t)
{ {
PacketQueue *q = &trans_q[t->inq->id]; PacketQueue *q = &trans_q[t->inq->id];
SCPerfSyncCountersIfSignalled(t); StatsSyncCountersIfSignalled(t);
SCMutexLock(&q->mutex_q); SCMutexLock(&q->mutex_q);

@ -868,7 +868,7 @@ static TmEcode UnixManager(ThreadVars *th_v, void *thread_data)
/* set the thread name */ /* set the thread name */
SCLogDebug("%s started...", th_v->name); SCLogDebug("%s started...", th_v->name);
SCPerfSetupPrivate(th_v); StatsSetupPrivate(th_v);
if (UnixNew(&command) == 0) { if (UnixNew(&command) == 0) {
int failure_fatal = 0; int failure_fatal = 0;
@ -897,7 +897,7 @@ static TmEcode UnixManager(ThreadVars *th_v, void *thread_data)
UnixManagerRegisterCommand("running-mode", UnixManagerRunningModeCommand, &command, 0); UnixManagerRegisterCommand("running-mode", UnixManagerRunningModeCommand, &command, 0);
UnixManagerRegisterCommand("capture-mode", UnixManagerCaptureModeCommand, &command, 0); UnixManagerRegisterCommand("capture-mode", UnixManagerCaptureModeCommand, &command, 0);
UnixManagerRegisterCommand("conf-get", UnixManagerConfGetCommand, &command, UNIX_CMD_TAKE_ARGS); UnixManagerRegisterCommand("conf-get", UnixManagerConfGetCommand, &command, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("dump-counters", SCPerfOutputCounterSocket, NULL, 0); UnixManagerRegisterCommand("dump-counters", StatsOutputCounterSocket, NULL, 0);
UnixManagerRegisterCommand("reload-rules", UnixManagerReloadRules, NULL, 0); UnixManagerRegisterCommand("reload-rules", UnixManagerReloadRules, NULL, 0);
TmThreadsSetFlag(th_v, THV_INIT_DONE); TmThreadsSetFlag(th_v, THV_INIT_DONE);
@ -914,7 +914,7 @@ static TmEcode UnixManager(ThreadVars *th_v, void *thread_data)
close(item->fd); close(item->fd);
SCFree(item); SCFree(item);
} }
SCPerfSyncCounters(th_v); StatsSyncCounters(th_v);
break; break;
} }

Loading…
Cancel
Save