]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-logopenfile: don't lock syslog write
authorEric Leblond <eric@regit.org>
Tue, 26 May 2015 10:06:26 +0000 (12:06 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 22 Oct 2015 08:01:05 +0000 (10:01 +0200)
src/util-logopenfile.c

index 91a1400ee550735f648ede18584e5b276ffb2764..431414fa5bd7a17b2de939f7ed47bf9cd2e64e64 100644 (file)
@@ -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;
 }