From: Victor Julien Date: Sat, 23 May 2015 11:41:49 +0000 (+0200) Subject: counters: make SCPerfSetupPrivate a function X-Git-Tag: suricata-3.0RC1~388 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac6e24c06a3110dd682ebfb925dbf8a0871a1fcb;p=thirdparty%2Fsuricata.git counters: make SCPerfSetupPrivate a function --- diff --git a/src/counters.c b/src/counters.c index c9e3075855..2e4546a200 100644 --- a/src/counters.c +++ b/src/counters.c @@ -1024,16 +1024,16 @@ uint16_t SCPerfRegisterMaxCounter(char *cname, char *tm_name, int type, return id; } -/** - * \brief Adds a TM to the clubbed TM table. Multiple instances of the same TM - * are stacked together in a PCTMI container. +/** \internal + * \brief Adds a TM to the clubbed TM table. Multiple instances of the same TM + * are stacked together in a PCTMI container. * - * \param tm_name Name of the tm to be added to the table - * \param pctx SCPerfPublicContext associated with the TM tm_name + * \param tm_name Name of the tm to be added to the table + * \param pctx SCPerfPublicContext associated with the TM tm_name * - * \retval 1 on success, 0 on failure + * \retval 1 on success, 0 on failure */ -int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfPublicContext *pctx) +static int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfPublicContext *pctx) { void *ptmp; if (sc_perf_op_ctx == NULL) { @@ -1138,14 +1138,14 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfPublicContext *pctx) return 1; } -/** - * \brief Returns a counter array for counters in this id range(s_id - e_id) +/** \internal + * \brief Returns a counter array for counters in this id range(s_id - e_id) * - * \param s_id Counter id of the first counter to be added to the array - * \param e_id Counter id of the last counter to be added to the array - * \param pctx Pointer to the tv's SCPerfPublicContext + * \param s_id Counter id of the first counter to be added to the array + * \param e_id Counter id of the last counter to be added to the array + * \param pctx Pointer to the tv's SCPerfPublicContext * - * \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, SCPerfPublicContext *pctx, @@ -1191,16 +1191,16 @@ static int SCPerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id, return 0; } -/** - * \brief Returns a counter array for all counters registered for this tm - * instance +/** \internal + * \brief Returns a counter array for all counters registered for this tm + * instance * - * \param pctx Pointer to the tv's SCPerfPublicContext + * \param pctx Pointer to the tv's SCPerfPublicContext * - * \retval pca Pointer to a counter-array for all counter of this tm instance - * on success; NULL on failure + * \retval pca Pointer to a counter-array for all counter of this tm instance + * on success; NULL on failure */ -int SCPerfGetAllCountersArray(SCPerfPublicContext *pctx, SCPerfPrivateContext *private) +static int SCPerfGetAllCountersArray(SCPerfPublicContext *pctx, SCPerfPrivateContext *private) { if (pctx == NULL || private == NULL) return -1; @@ -1208,6 +1208,17 @@ int SCPerfGetAllCountersArray(SCPerfPublicContext *pctx, SCPerfPrivateContext *p return SCPerfGetCounterArrayRange(1, pctx->curr_id, pctx, private); } + +int SCPerfSetupPrivate(ThreadVars *tv) +{ + SCPerfGetAllCountersArray(&(tv)->perf_public_ctx, &(tv)->perf_private_ctx); + + SCPerfAddToClubbedTMTable((tv->thread_group_name != NULL) ? + tv->thread_group_name : tv->name, + &(tv)->perf_public_ctx); + return 0; +} + /** * \brief Syncs the counter array with the global counter variables * diff --git a/src/counters.h b/src/counters.h index ff00e0d89a..a63cc5bb4a 100644 --- a/src/counters.h +++ b/src/counters.h @@ -163,10 +163,9 @@ uint16_t SCPerfRegisterAvgCounter(char *, char *, int, char *, SCPerfPublicConte uint16_t SCPerfRegisterMaxCounter(char *, char *, int, char *, SCPerfPublicContext *); /* utility functions */ -int SCPerfAddToClubbedTMTable(char *, SCPerfPublicContext *); -int SCPerfGetAllCountersArray(SCPerfPublicContext *, SCPerfPrivateContext *); int SCPerfUpdateCounterArray(SCPerfPrivateContext *, SCPerfPublicContext *); uint64_t SCPerfGetLocalCounterValue(struct ThreadVars_ *, uint16_t); +int SCPerfSetupPrivate(struct ThreadVars_ *); /* functions used to free the resources alloted by the Perf counter API */ void SCPerfReleaseResources(void); @@ -189,16 +188,6 @@ void SCPerfCounterIncr(struct ThreadVars_ *, uint16_t); } \ } while (0) -#define SCPerfSetupPrivate(tv) \ - do { \ - SCPerfGetAllCountersArray(&(tv)->perf_public_ctx, \ - &(tv)->perf_private_ctx); \ - \ - SCPerfAddToClubbedTMTable(((tv)->thread_group_name != NULL) ? \ - (tv)->thread_group_name : (tv)->name, \ - &(tv)->perf_public_ctx); \ - } while (0) - #ifdef BUILD_UNIX_SOCKET #include TmEcode SCPerfOutputCounterSocket(json_t *cmd,