]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
counters: make SCPerfSetupPrivate a function
authorVictor Julien <victor@inliniac.net>
Sat, 23 May 2015 11:41:49 +0000 (13:41 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 26 May 2015 15:56:56 +0000 (17:56 +0200)
src/counters.c
src/counters.h

index c9e30758555050c9f105f4e4c7dedb7479d794a4..2e4546a2001fb0a0b779dbccfd172a77e9d4d05e 100644 (file)
@@ -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
  *
index ff00e0d89a549152663c8292fc84136bdb721921..a63cc5bb4a4e2ca3f30ab2d0c0baff72608b61b4 100644 (file)
@@ -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,