counters: split API init

Split into early ctx initialization and post-config setup.
pull/1508/head
Victor Julien 11 years ago
parent d05eed3735
commit 33756abd87

@ -212,12 +212,6 @@ static ConfNode *GetConfig(void) {
static void SCPerfInitOPCtx(void)
{
SCEnter();
if ( (sc_perf_op_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCPerfInitOPCtx. Exiting...");
exit(EXIT_FAILURE);
}
memset(sc_perf_op_ctx, 0, sizeof(StatsGlobalContext));
ConfNode *stats = GetConfig();
if (stats != NULL) {
const char *enabled = ConfNodeLookupChildValue(stats, "enabled");
@ -797,11 +791,19 @@ TmEcode SCPerfOutputCounterSocket(json_t *cmd,
* \brief Initializes the perf counter api. Things are hard coded currently.
* More work to be done when we implement multiple interfaces
*/
void SCPerfInitCounterApi(void)
void StatsInit(void)
{
SCPerfInitOPCtx();
BUG_ON(sc_perf_op_ctx != NULL);
if ( (sc_perf_op_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SCPerfInitOPCtx. Exiting...");
exit(EXIT_FAILURE);
}
memset(sc_perf_op_ctx, 0, sizeof(StatsGlobalContext));
}
return;
void StatsSetupPostConfig(void)
{
SCPerfInitOPCtx();
}
/**

@ -111,7 +111,8 @@ typedef struct SCPerfPrivateContext_ {
} SCPerfPrivateContext;
/* the initialization functions */
void SCPerfInitCounterApi(void);
void StatsInit(void);
void StatsSetupPostConfig(void);
void SCPerfSpawnThreads(void);
void SCPerfRegisterTests(void);

@ -344,6 +344,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data)
return TM_ECODE_FAILED;
}
PcapFilesFree(cfile);
StatsInit();
#ifdef PROFILING
SCProfilingRulesGlobalInit();
SCProfilingKeywordsGlobalInit();
@ -354,7 +355,7 @@ TmEcode UnixSocketPcapFilesCheck(void *data)
IPPairInitConfig(FLOW_QUIET);
StreamTcpInitConfig(STREAM_VERBOSE);
RunModeInitializeOutputs();
SCPerfInitCounterApi();
StatsSetupPostConfig();
RunModeDispatch(RUNMODE_PCAP_FILE, NULL);
FlowManagerThreadSpawn();
FlowRecyclerThreadSpawn();

@ -2203,6 +2203,7 @@ int main(int argc, char **argv)
GlobalInits();
TimeInit();
SupportFastPatternForSigMatchTypes();
StatsInit();
if (conf_filename == NULL)
conf_filename = DEFAULT_CONF_FILE;
@ -2302,7 +2303,7 @@ int main(int argc, char **argv)
if (suri.run_mode != RUNMODE_UNIX_SOCKET) {
RunModeInitializeOutputs();
SCPerfInitCounterApi();
StatsSetupPostConfig();
}
if (ParseInterfacesList(suri.run_mode, suri.pcap_dev) != TM_ECODE_OK) {

Loading…
Cancel
Save