flow: flow log threading setup

Set up threading for the flow logger.
pull/1058/head
Victor Julien 11 years ago
parent e30c083cff
commit c7ebfd1b68

@ -354,6 +354,76 @@ error:
exit(EXIT_FAILURE);
}
/**
* \brief Register a flow output module.
*
* This function will register an output module so it can be
* configured with the configuration file.
*
* \retval Returns 0 on success, -1 on failure.
*/
void
OutputRegisterFlowModule(const char *name, const char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *), FlowLogger FlowLogFunc)
{
if (unlikely(FlowLogFunc == NULL)) {
goto error;
}
OutputModule *module = SCCalloc(1, sizeof(*module));
if (unlikely(module == NULL)) {
goto error;
}
module->name = name;
module->conf_name = conf_name;
module->InitFunc = InitFunc;
module->FlowLogFunc = FlowLogFunc;
TAILQ_INSERT_TAIL(&output_modules, module, entries);
SCLogDebug("Flow logger \"%s\" registered.", name);
return;
error:
SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
exit(EXIT_FAILURE);
}
/**
* \brief Register a flow output sub-module.
*
* This function will register an output module so it can be
* configured with the configuration file.
*
* \retval Returns 0 on success, -1 on failure.
*/
void
OutputRegisterFlowSubModule(const char *parent_name, const char *name,
const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
FlowLogger FlowLogFunc)
{
if (unlikely(FlowLogFunc == NULL)) {
goto error;
}
OutputModule *module = SCCalloc(1, sizeof(*module));
if (unlikely(module == NULL)) {
goto error;
}
module->name = name;
module->conf_name = conf_name;
module->parent_name = parent_name;
module->InitSubFunc = InitFunc;
module->FlowLogFunc = FlowLogFunc;
TAILQ_INSERT_TAIL(&output_modules, module, entries);
SCLogDebug("Flow logger \"%s\" registered.", name);
return;
error:
SCLogError(SC_ERR_FATAL, "Fatal error encountered. Exiting...");
exit(EXIT_FAILURE);
}
/**
* \brief Get an output module by name.
*

@ -34,6 +34,7 @@
#include "output-tx.h"
#include "output-file.h"
#include "output-filedata.h"
#include "output-flow.h"
typedef struct OutputModule_ {
const char *name;
@ -47,6 +48,7 @@ typedef struct OutputModule_ {
TxLogger TxLogFunc;
FileLogger FileLogFunc;
FiledataLogger FiledataLogFunc;
FlowLogger FlowLogFunc;
AppProto alproto;
TAILQ_ENTRY(OutputModule_) entries;
@ -80,6 +82,12 @@ void OutputRegisterFiledataSubModule(const char *parent_name, const char *name,
const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
FiledataLogger FiledataLogFunc);
void OutputRegisterFlowModule(const char *name, const char *conf_name,
OutputCtx *(*InitFunc)(ConfNode *), FlowLogger FlowLogFunc);
void OutputRegisterFlowSubModule(const char *parent_name, const char *name,
const char *conf_name, OutputCtx *(*InitFunc)(ConfNode *, OutputCtx *),
FlowLogger FlowLogFunc);
OutputModule *OutputGetModuleByConfName(const char *name);
void OutputDeregisterAll(void);

@ -484,6 +484,12 @@ static void AddOutputToFreeList(OutputModule *module, OutputCtx *output_ctx)
/** \brief Turn output into thread module */
static void SetupOutput(const char *name, OutputModule *module, OutputCtx *output_ctx)
{
/* flow logger doesn't run in the packet path */
if (module->FlowLogFunc) {
OutputRegisterFlowLogger(module->name, module->FlowLogFunc, output_ctx);
return;
}
TmModule *tm_module = TmModuleGetByName(module->name);
if (tm_module == NULL) {
SCLogError(SC_ERR_INVALID_ARGUMENT,

Loading…
Cancel
Save