/**
* \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
*
* \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
*/
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;
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;
}
* 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);
* 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);
* 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);
* 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) {
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) {
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);
}
ptmp = SCRealloc(pctmi->head,
- (pctmi->size + 1) * sizeof(SCPerfContext **));
+ (pctmi->size + 1) * sizeof(SCPerfPublicContext **));
if (ptmp == NULL) {
SCFree(pctmi->head);
pctmi->head = NULL;
*
* \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;
* \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):
* \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;
#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);
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);
/**
* \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;
/* mutex to prevent simultaneous access during update_counter/output_stat */
SCMutex m;
-} SCPerfContext;
+} SCPerfPublicContext;
/**
* \brief Node elements used by the SCPerfPrivateContext(PCA) Node
typedef struct SCPerfClubTMInst_ {
char *tm_name;
- SCPerfContext **head;
+ SCPerfPublicContext **head;
uint32_t size;
struct SCPerfClubTMInst_ *next;
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 */