counters: make SCPerfSetupPrivate a function

pull/1508/head
Victor Julien 10 years ago
parent 66635f0741
commit ac6e24c06a

@ -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
*

@ -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 <jansson.h>
TmEcode SCPerfOutputCounterSocket(json_t *cmd,

Loading…
Cancel
Save