From 404e66041091008dc67b5fa4ea4f814384d63af4 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Tue, 26 May 2015 12:06:26 +0200 Subject: [PATCH] util-logopenfile: don't lock syslog write --- src/util-logopenfile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index 91a1400ee5..431414fa5b 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -606,23 +606,25 @@ static int LogFileWriteRedis(LogFileCtx *file_ctx, char *string, size_t string_ int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer, char *string, size_t string_len) { - SCMutexLock(&file_ctx->fp_mutex); if (file_ctx->type == LOGFILE_TYPE_SYSLOG) { syslog(file_ctx->syslog_setup.alert_syslog_level, "%s", string); } else if (file_ctx->type == LOGFILE_TYPE_FILE || file_ctx->type == LOGFILE_TYPE_UNIX_DGRAM || file_ctx->type == LOGFILE_TYPE_UNIX_STREAM) { + SCMutexLock(&file_ctx->fp_mutex); MemBufferWriteString(buffer, "%s\n", string); file_ctx->Write((const char *)MEMBUFFER_BUFFER(buffer), MEMBUFFER_OFFSET(buffer), file_ctx); + SCMutexUnlock(&file_ctx->fp_mutex); } #ifdef HAVE_LIBHIREDIS else if (file_ctx->type == LOGFILE_TYPE_REDIS) { + SCMutexLock(&file_ctx->fp_mutex); LogFileWriteRedis(file_ctx, string, string_len); + SCMutexUnlock(&file_ctx->fp_mutex); } #endif - SCMutexUnlock(&file_ctx->fp_mutex); return 0; }