From 08a33b1d8948478a92aabbdb864bef04ece46177 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 22 Apr 2019 07:19:21 -0400 Subject: [PATCH] ... --- MagickCore/log.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/MagickCore/log.c b/MagickCore/log.c index b5dee6e90..0efab8ea2 100644 --- a/MagickCore/log.c +++ b/MagickCore/log.c @@ -137,11 +137,14 @@ struct _LogInfo TimerInfo timer; - size_t - signature; - MagickLogMethod method; + + SemaphoreInfo + *event_semaphore; + + size_t + signature; }; typedef struct _LogMapInfo @@ -214,7 +217,6 @@ static MagickBooleanType event_logging = MagickFalse; static SemaphoreInfo - *event_semaphore = (SemaphoreInfo *) NULL, *log_semaphore = (SemaphoreInfo *) NULL; /* @@ -850,7 +852,6 @@ MagickPrivate MagickBooleanType LogComponentGenesis(void) exception=AcquireExceptionInfo(); (void) GetLogInfo("*",exception); exception=DestroyExceptionInfo(exception); - event_semaphore=AcquireSemaphoreInfo(); return(MagickTrue); } @@ -891,17 +892,17 @@ static void *DestroyLogElement(void *log_info) p->path=DestroyString(p->path); if (p->filename != (char *) NULL) p->filename=DestroyString(p->filename); + if (p->event_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&p->event_semaphore); + LockSemaphoreInfo(p->event_semaphore); + UnlockSemaphoreInfo(p->event_semaphore); + RelinquishSemaphoreInfo(&p->event_semaphore); p=(LogInfo *) RelinquishMagickMemory(p); return((void *) NULL); } MagickPrivate void LogComponentTerminus(void) { - if (event_semaphore == (SemaphoreInfo *) NULL) - ActivateSemaphoreInfo(&event_semaphore); - LockSemaphoreInfo(event_semaphore); - UnlockSemaphoreInfo(event_semaphore); - RelinquishSemaphoreInfo(&event_semaphore); if (log_semaphore == (SemaphoreInfo *) NULL) ActivateSemaphoreInfo(&log_semaphore); LockSemaphoreInfo(log_semaphore); @@ -1291,12 +1292,12 @@ MagickExport MagickBooleanType LogMagickEventList(const LogEventType type, exception=AcquireExceptionInfo(); log_info=(LogInfo *) GetLogInfo("*",exception); exception=DestroyExceptionInfo(exception); - if (event_semaphore == (SemaphoreInfo *) NULL) - ActivateSemaphoreInfo(&event_semaphore); - LockSemaphoreInfo(event_semaphore); + if (log_info->event_semaphore == (SemaphoreInfo *) NULL) + ActivateSemaphoreInfo(&log_info->event_semaphore); + LockSemaphoreInfo(log_info->event_semaphore); if ((log_info->event_mask & type) == 0) { - UnlockSemaphoreInfo(event_semaphore); + UnlockSemaphoreInfo(log_info->event_semaphore); return(MagickTrue); } domain=CommandOptionToMnemonic(MagickLogEventOptions,type); @@ -1311,7 +1312,7 @@ MagickExport MagickBooleanType LogMagickEventList(const LogEventType type, if (text == (char *) NULL) { (void) ContinueTimer((TimerInfo *) &log_info->timer); - UnlockSemaphoreInfo(event_semaphore); + UnlockSemaphoreInfo(log_info->event_semaphore); return(MagickFalse); } if ((log_info->handler_mask & ConsoleHandler) != 0) @@ -1340,7 +1341,7 @@ MagickExport MagickBooleanType LogMagickEventList(const LogEventType type, file_info.st_size=0; if (log_info->file != (FILE *) NULL) (void) fstat(fileno(log_info->file),&file_info); - if (file_info.st_size > (ssize_t) (1024*1024*log_info->limit)) + if (file_info.st_size > (MagickOffsetType) (1024*1024*log_info->limit)) { (void) FormatLocaleFile(log_info->file,"\n"); (void) fclose(log_info->file); @@ -1355,7 +1356,7 @@ MagickExport MagickBooleanType LogMagickEventList(const LogEventType type, if (filename == (char *) NULL) { (void) ContinueTimer((TimerInfo *) &log_info->timer); - UnlockSemaphoreInfo(event_semaphore); + UnlockSemaphoreInfo(log_info->event_semaphore); return(MagickFalse); } log_info->append=IsPathAccessible(filename); @@ -1363,7 +1364,7 @@ MagickExport MagickBooleanType LogMagickEventList(const LogEventType type, filename=(char *) RelinquishMagickMemory(filename); if (log_info->file == (FILE *) NULL) { - UnlockSemaphoreInfo(event_semaphore); + UnlockSemaphoreInfo(log_info->event_semaphore); return(MagickFalse); } log_info->generation++; @@ -1392,7 +1393,7 @@ MagickExport MagickBooleanType LogMagickEventList(const LogEventType type, } text=(char *) RelinquishMagickMemory(text); (void) ContinueTimer((TimerInfo *) &log_info->timer); - UnlockSemaphoreInfo(event_semaphore); + UnlockSemaphoreInfo(log_info->event_semaphore); return(MagickTrue); } -- 2.40.0