counters: s/SCPerfContext/SCPerfPublicContext/g

pull/1508/head
Victor Julien 11 years ago
parent 0a5ae1b403
commit 6ffbc3a362

@ -334,7 +334,7 @@ static void *SCPerfMgmtThread(void *arg)
/**
* \brief Wake up thread. This thread wakes up every TTS(time to sleep) seconds
* and sets the flag for every ThreadVars' SCPerfContext
* and sets the flag for every ThreadVars' SCPerfPublicContext
*
* \param arg is NULL always
*
@ -465,7 +465,7 @@ static void SCPerfReleaseCounter(SCPerfCounter *pc)
* \param tm_name Thread module to which this counter belongs
* \param type Datatype of this counter variable
* \param desc Description of this counter
* \param pctx SCPerfContext for this tm-tv instance
* \param pctx SCPerfPublicContext for this tm-tv instance
* \param type_q Qualifier describing the type of counter to be registered
*
* \retval the counter id for the newly registered counter, or the already
@ -474,7 +474,7 @@ static void SCPerfReleaseCounter(SCPerfCounter *pc)
*/
static uint16_t SCPerfRegisterQualifiedCounter(char *cname, char *tm_name,
int type, char *desc,
SCPerfContext *pctx, int type_q)
SCPerfPublicContext *pctx, int type_q)
{
SCPerfCounter **head = &pctx->head;
SCPerfCounter *temp = NULL;
@ -482,7 +482,7 @@ static uint16_t SCPerfRegisterQualifiedCounter(char *cname, char *tm_name,
SCPerfCounter *pc = NULL;
if (cname == NULL || tm_name == NULL || pctx == NULL) {
SCLogDebug("Counter name, tm name null or SCPerfContext NULL");
SCLogDebug("Counter name, tm name null or SCPerfPublicContext NULL");
return 0;
}
@ -962,14 +962,14 @@ uint16_t SCPerfTVRegisterMaxCounter(char *cname, struct ThreadVars_ *tv,
* registered
* \param type Datatype of this counter variable
* \param desc Description of this counter
* \param pctx SCPerfContext corresponding to the tm_name key under which the
* \param pctx SCPerfPublicContext corresponding to the tm_name key under which the
* key has to be registered
*
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
uint16_t SCPerfRegisterCounter(char *cname, char *tm_name, int type, char *desc,
SCPerfContext *pctx)
SCPerfPublicContext *pctx)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tm_name, type, desc,
pctx, SC_PERF_TYPE_Q_NORMAL);
@ -986,14 +986,14 @@ uint16_t SCPerfRegisterCounter(char *cname, char *tm_name, int type, char *desc,
* registered
* \param type Datatype of this counter variable
* \param desc Description of this counter
* \param pctx SCPerfContext corresponding to the tm_name key under which the
* \param pctx SCPerfPublicContext corresponding to the tm_name key under which the
* key has to be registered
*
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
uint16_t SCPerfRegisterAvgCounter(char *cname, char *tm_name, int type,
char *desc, SCPerfContext *pctx)
char *desc, SCPerfPublicContext *pctx)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tm_name, type, desc,
pctx, SC_PERF_TYPE_Q_AVERAGE);
@ -1010,14 +1010,14 @@ uint16_t SCPerfRegisterAvgCounter(char *cname, char *tm_name, int type,
* registered
* \param type Datatype of this counter variable
* \param desc Description of this counter
* \param pctx SCPerfContext corresponding to the tm_name key under which the
* \param pctx SCPerfPublicContext corresponding to the tm_name key under which the
* key has to be registered
*
* \retval id Counter id for the newly registered counter, or the already
* present counter
*/
uint16_t SCPerfRegisterMaxCounter(char *cname, char *tm_name, int type,
char *desc, SCPerfContext *pctx)
char *desc, SCPerfPublicContext *pctx)
{
uint16_t id = SCPerfRegisterQualifiedCounter(cname, tm_name, type, desc,
pctx, SC_PERF_TYPE_Q_MAXIMUM);
@ -1030,11 +1030,11 @@ uint16_t SCPerfRegisterMaxCounter(char *cname, char *tm_name, int type,
* are stacked together in a PCTMI container.
*
* \param tm_name Name of the tm to be added to the table
* \param pctx SCPerfContext associated with the TM tm_name
* \param pctx SCPerfPublicContext associated with the TM tm_name
*
* \retval 1 on success, 0 on failure
*/
int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfPublicContext *pctx)
{
void *ptmp;
if (sc_perf_op_ctx == NULL) {
@ -1045,7 +1045,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
SCPerfClubTMInst *pctmi = NULL;
SCPerfClubTMInst *prev = NULL;
SCPerfClubTMInst *temp = NULL;
SCPerfContext **hpctx = NULL;
SCPerfPublicContext **hpctx = NULL;
uint32_t u = 0;
if (tm_name == NULL || pctx == NULL) {
@ -1077,7 +1077,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
memset(temp, 0, sizeof(SCPerfClubTMInst));
temp->size = 1;
temp->head = SCMalloc(sizeof(SCPerfContext **));
temp->head = SCMalloc(sizeof(SCPerfPublicContext **));
if (temp->head == NULL) {
SCFree(temp);
SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
@ -1112,7 +1112,7 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
}
ptmp = SCRealloc(pctmi->head,
(pctmi->size + 1) * sizeof(SCPerfContext **));
(pctmi->size + 1) * sizeof(SCPerfPublicContext **));
if (ptmp == NULL) {
SCFree(pctmi->head);
pctmi->head = NULL;
@ -1144,12 +1144,12 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
*
* \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 SCPerfContext
* \param pctx Pointer to the tv's SCPerfPublicContext
*
* \retval a counter-array in this(s_id-e_id) range for this TM instance
*/
SCPerfPrivateContext *SCPerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id,
SCPerfContext *pctx)
SCPerfPublicContext *pctx)
{
SCPerfCounter *pc = NULL;
SCPerfPrivateContext *pca = NULL;
@ -1200,12 +1200,12 @@ SCPerfPrivateContext *SCPerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id,
* \brief Returns a counter array for all counters registered for this tm
* instance
*
* \param pctx Pointer to the tv's SCPerfContext
* \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
*/
SCPerfPrivateContext *SCPerfGetAllCountersArray(SCPerfContext *pctx)
SCPerfPrivateContext *SCPerfGetAllCountersArray(SCPerfPublicContext *pctx)
{
SCPerfPrivateContext *pca = ((pctx)?
SCPerfGetCounterArrayRange(1, pctx->curr_id, pctx):
@ -1218,12 +1218,12 @@ SCPerfPrivateContext *SCPerfGetAllCountersArray(SCPerfContext *pctx)
* \brief Syncs the counter array with the global counter variables
*
* \param pca Pointer to the SCPerfPrivateContext
* \param pctx Pointer the the tv's SCPerfContext
* \param pctx Pointer the the tv's SCPerfPublicContext
*
* \retval 0 on success
* \retval -1 on error
*/
int SCPerfUpdateCounterArray(SCPerfPrivateContext *pca, SCPerfContext *pctx)
int SCPerfUpdateCounterArray(SCPerfPrivateContext *pca, SCPerfPublicContext *pctx)
{
SCPerfCounter *pc = NULL;
SCPCAElem *pcae = NULL;
@ -1330,28 +1330,28 @@ void SCPerfReleasePCA(SCPerfPrivateContext *pca)
#ifdef UNITTESTS
static int SCPerfTestCounterReg01()
{
SCPerfContext pctx;
SCPerfPublicContext pctx;
memset(&pctx, 0, sizeof(SCPerfContext));
memset(&pctx, 0, sizeof(SCPerfPublicContext));
return SCPerfRegisterCounter("t1", "c1", 5, NULL, &pctx);
}
static int SCPerfTestCounterReg02()
{
SCPerfContext pctx;
SCPerfPublicContext pctx;
memset(&pctx, 0, sizeof(SCPerfContext));
memset(&pctx, 0, sizeof(SCPerfPublicContext));
return SCPerfRegisterCounter(NULL, NULL, SC_PERF_TYPE_UINT64, NULL, &pctx);
}
static int SCPerfTestCounterReg03()
{
SCPerfContext pctx;
SCPerfPublicContext pctx;
int result;
memset(&pctx, 0, sizeof(SCPerfContext));
memset(&pctx, 0, sizeof(SCPerfPublicContext));
result = SCPerfRegisterCounter("t1", "c1", SC_PERF_TYPE_UINT64, NULL, &pctx);
@ -1362,10 +1362,10 @@ static int SCPerfTestCounterReg03()
static int SCPerfTestCounterReg04()
{
SCPerfContext pctx;
SCPerfPublicContext pctx;
int result;
memset(&pctx, 0, sizeof(SCPerfContext));
memset(&pctx, 0, sizeof(SCPerfPublicContext));
SCPerfRegisterCounter("t1", "c1", SC_PERF_TYPE_UINT64, NULL, &pctx);
SCPerfRegisterCounter("t2", "c2", SC_PERF_TYPE_UINT64, NULL, &pctx);

@ -82,7 +82,7 @@ typedef struct SCPerfCounter_ {
/**
* \brief Holds the Perf Context for a ThreadVars instance
*/
typedef struct SCPerfContext_ {
typedef struct SCPerfPublicContext_ {
/* flag set by the wakeup thread, to inform the client threads to sync */
uint32_t perf_flag;
@ -94,7 +94,7 @@ typedef struct SCPerfContext_ {
/* mutex to prevent simultaneous access during update_counter/output_stat */
SCMutex m;
} SCPerfContext;
} SCPerfPublicContext;
/**
* \brief Node elements used by the SCPerfPrivateContext(PCA) Node
@ -130,7 +130,7 @@ typedef struct SCPerfPrivateContext_ {
typedef struct SCPerfClubTMInst_ {
char *tm_name;
SCPerfContext **head;
SCPerfPublicContext **head;
uint32_t size;
struct SCPerfClubTMInst_ *next;
@ -154,16 +154,16 @@ uint16_t SCPerfTVRegisterAvgCounter(char *, struct ThreadVars_ *, int, char *);
uint16_t SCPerfTVRegisterMaxCounter(char *, struct ThreadVars_ *, int, char *);
/* the non-ThreadVars counter registration functions */
uint16_t SCPerfRegisterCounter(char *, char *, int, char *, SCPerfContext *);
uint16_t SCPerfRegisterAvgCounter(char *, char *, int, char *, SCPerfContext *);
uint16_t SCPerfRegisterMaxCounter(char *, char *, int, char *, SCPerfContext *);
uint16_t SCPerfRegisterCounter(char *, char *, int, char *, SCPerfPublicContext *);
uint16_t SCPerfRegisterAvgCounter(char *, char *, int, char *, SCPerfPublicContext *);
uint16_t SCPerfRegisterMaxCounter(char *, char *, int, char *, SCPerfPublicContext *);
/* utility functions */
int SCPerfAddToClubbedTMTable(char *, SCPerfContext *);
SCPerfPrivateContext *SCPerfGetCounterArrayRange(uint16_t, uint16_t, SCPerfContext *);
SCPerfPrivateContext * SCPerfGetAllCountersArray(SCPerfContext *);
int SCPerfAddToClubbedTMTable(char *, SCPerfPublicContext *);
SCPerfPrivateContext *SCPerfGetCounterArrayRange(uint16_t, uint16_t, SCPerfPublicContext *);
SCPerfPrivateContext * SCPerfGetAllCountersArray(SCPerfPublicContext *);
int SCPerfUpdateCounterArray(SCPerfPrivateContext *, SCPerfContext *);
int SCPerfUpdateCounterArray(SCPerfPrivateContext *, SCPerfPublicContext *);
double SCPerfGetLocalCounterValue(uint16_t, SCPerfPrivateContext *);
/* functions used to free the resources alloted by the Perf counter API */

@ -104,7 +104,7 @@ typedef struct ThreadVars_ {
/* counters */
/** public counter store: counter syncs update this */
SCPerfContext sc_perf_pctx;
SCPerfPublicContext sc_perf_pctx;
/** private counter store: counter updates modify this */
SCPerfPrivateContext *sc_perf_pca;

Loading…
Cancel
Save