From b8e741de9eaadf50d13dea48b6d171b87682975f Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 2 Apr 2012 15:45:16 +0200 Subject: [PATCH] Minor optimizations to unified2 and fast.log. --- src/alert-fastlog.c | 10 ++++------ src/alert-unified2-alert.c | 5 +---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index 256c16bba7..c162482a97 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -130,8 +130,11 @@ TmEcode AlertFastLogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, CreateTimeString(&p->ts, timebuf, sizeof(timebuf)); - SCMutexLock(&aft->file_ctx->fp_mutex); + char srcip[16], dstip[16]; + PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); + PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); + SCMutexLock(&aft->file_ctx->fp_mutex); aft->file_ctx->alerts += p->alerts.cnt; for (i = 0; i < p->alerts.cnt; i++) { @@ -140,11 +143,6 @@ TmEcode AlertFastLogIPv4(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, continue; } - char srcip[16], dstip[16]; - - PrintInet(AF_INET, (const void *)GET_IPV4_SRC_ADDR_PTR(p), srcip, sizeof(srcip)); - PrintInet(AF_INET, (const void *)GET_IPV4_DST_ADDR_PTR(p), dstip, sizeof(dstip)); - if (pa->action & ACTION_DROP && IS_ENGINE_MODE_IPS(engine_mode)) { action = "[Drop] "; } else if (pa->action & ACTION_DROP) { diff --git a/src/alert-unified2-alert.c b/src/alert-unified2-alert.c index d07aaab9fd..7850a4b0fe 100644 --- a/src/alert-unified2-alert.c +++ b/src/alert-unified2-alert.c @@ -1064,13 +1064,10 @@ int Unified2IPv4TypeAlert (ThreadVars *tv, Packet *p, void *data, PacketQueue *p return -1; } fflush(aun->file_ctx->fp); + aun->file_ctx->alerts++; SCMutexUnlock(&aun->file_ctx->fp_mutex); } - SCMutexLock(&aun->file_ctx->fp_mutex); - aun->file_ctx->alerts += p->alerts.cnt; - SCMutexUnlock(&aun->file_ctx->fp_mutex); - return 0; } -- 2.47.2