util-logopenfile: don't allocate redis command

As we only have two different commands we don't need to allocate
it and can use pointer to global variables.
pull/1712/head
Eric Leblond 10 years ago committed by Victor Julien
parent 2ea4bbc492
commit d88e133428

@ -34,6 +34,9 @@
#include "util-logopenfile.h"
#include "util-logopenfile-tile.h"
const char * redis_push_cmd = "LPUSH";
const char * redis_publish_cmd = "PUBLISH";
/** \brief connect to the indicated local stream socket, logging any errors
* \param path filesystem path to connect to
* \param log_err, non-zero if connect failure should be logged.
@ -399,13 +402,13 @@ int SCConfLogOpenRedis(ConfNode *redis_node, LogFileCtx *log_ctx)
}
if (!strcmp(redis_mode, "list")) {
log_ctx->redis_setup.command = SCStrdup("LPUSH");
log_ctx->redis_setup.command = redis_push_cmd;
if (!log_ctx->redis_setup.command) {
SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis key command");
exit(EXIT_FAILURE);
}
} else {
log_ctx->redis_setup.command = SCStrdup("PUBLISH");
log_ctx->redis_setup.command = redis_publish_cmd;
if (!log_ctx->redis_setup.command) {
SCLogError(SC_ERR_MEM_ALLOC, "Unable to allocate redis key command");
exit(EXIT_FAILURE);
@ -509,8 +512,6 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
redisFree(lf_ctx->redis);
if (lf_ctx->redis_setup.server)
SCFree(lf_ctx->redis_setup.server);
if (lf_ctx->redis_setup.command)
SCFree(lf_ctx->redis_setup.command);
if (lf_ctx->redis_setup.key)
SCFree(lf_ctx->redis_setup.key);
}

@ -51,7 +51,7 @@ enum RedisMode { REDIS_LIST, REDIS_CHANNEL };
typedef struct RedisSetup_ {
enum RedisMode mode;
char *command;
const char *command;
char *key;
int batch_size;
int batch_count;

Loading…
Cancel
Save