From 9241c26f2fe0d1201e43e22ed05900c0ecafe9ba Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:43:51 -0500 Subject: [PATCH 1/7] Move PATH_MAX to zm_config where all the other defines are --- src/zm.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/zm.h b/src/zm.h index 092561378..ad0f89584 100644 --- a/src/zm.h +++ b/src/zm.h @@ -17,9 +17,6 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -#if !defined(PATH_MAX) -#define PATH_MAX 1024 -#endif #ifndef ZM_H #define ZM_H From 5ad753b6b432773495c1226a6b61fa0e07c5a250 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:44:10 -0500 Subject: [PATCH 2/7] zm_comms uses logging functions, so include zm_logger.h --- src/zm_comms.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zm_comms.h b/src/zm_comms.h index 133c0d19f..e93951a85 100644 --- a/src/zm_comms.h +++ b/src/zm_comms.h @@ -20,6 +20,7 @@ #ifndef ZM_COMMS_H #define ZM_COMMS_H +#include "zm_logger.h" #include "zm_exception.h" #include From 48564da9157da9ea37498dfd900493825a5d8815 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:44:34 -0500 Subject: [PATCH 3/7] zm_config.h shouldn't include zm.h. zm.h includs zm_config.h --- src/zm_config.h.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zm_config.h.in b/src/zm_config.h.in index f321095df..87a0f2db4 100644 --- a/src/zm_config.h.in +++ b/src/zm_config.h.in @@ -20,9 +20,11 @@ #ifndef ZM_CONFIG_H #define ZM_CONFIG_H +#if !defined(PATH_MAX) +#define PATH_MAX 1024 +#endif #include "config.h" #include "zm_config_defines.h" -#include "zm.h" #include From af8626158dbc81a36da5132fe6f21dd5483c1657 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:44:54 -0500 Subject: [PATCH 4/7] zm_exception doesn't use anything from zm.h so don't include it --- src/zm_exception.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/zm_exception.h b/src/zm_exception.h index 83d1ecab1..a02653b88 100644 --- a/src/zm_exception.h +++ b/src/zm_exception.h @@ -20,8 +20,6 @@ #ifndef ZM_EXCEPTION_H #define ZM_EXCEPTION_H -#include "zm.h" - #include class Exception From 61759a1f2d4e89598d56982502939ffaf5ad1713 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:45:21 -0500 Subject: [PATCH 5/7] older libavcodecs don't have AV_LOG_TRACE AND AV_LOG_MAX_OFFSET --- src/zm_ffmpeg.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/zm_ffmpeg.cpp b/src/zm_ffmpeg.cpp index 00aee7961..a153dad10 100644 --- a/src/zm_ffmpeg.cpp +++ b/src/zm_ffmpeg.cpp @@ -43,10 +43,14 @@ void log_libav_callback( void *ptr, int level, const char *fmt, va_list vargs ) log_level = Logger::DEBUG1; } else if ( level == AV_LOG_DEBUG ) { //48 log_level = Logger::DEBUG2; +#ifdef AV_LOG_TRACE } else if ( level == AV_LOG_TRACE ) { log_level = Logger::DEBUG8; +#endif +#ifdef AV_LOG_MAX_OFFSET } else if ( level == AV_LOG_MAX_OFFSET ) { log_level = Logger::DEBUG9; +#endif } else { Error("Unknown log level %d", level); } From 4d4666f5e03fc1c380444f7219ef7a1e8a827a1e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:45:41 -0500 Subject: [PATCH 6/7] add a mutex in logging functions so that multiple threads can log at the same time --- src/zm_logger.cpp | 2 ++ src/zm_logger.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/zm_logger.cpp b/src/zm_logger.cpp index 9740a100f..c34f6ba41 100644 --- a/src/zm_logger.cpp +++ b/src/zm_logger.cpp @@ -444,6 +444,7 @@ void Logger::closeSyslog() { void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) { if ( level > mEffectiveLevel ) return; + log_mutex.lock(); char timeString[64]; char logString[8192]; va_list argPtr; @@ -579,6 +580,7 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co abort(); exit(-1); } + log_mutex.unlock(); } diff --git a/src/zm_logger.h b/src/zm_logger.h index 8e2ab6c9d..f65c5ec31 100644 --- a/src/zm_logger.h +++ b/src/zm_logger.h @@ -30,6 +30,8 @@ #endif // HAVE_SYS_SYSCALL_H #include +#include "zm_thread.h" + class Logger { public: enum { @@ -82,6 +84,8 @@ private: static bool smInitialised; static Logger *smInstance; + RecursiveMutex log_mutex; + static StringMap smCodes; static IntMap smSyslogPriorities; From 522ecaddd890796b8a384bf5b484e471bd3c27d4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Nov 2018 12:46:10 -0500 Subject: [PATCH 7/7] remove extra include unistd.h and we have to pre-define RecursiveMutex because we use it in zm_logger. --- src/zm_thread.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/zm_thread.h b/src/zm_thread.h index 0c41a93a5..8cdfb892c 100644 --- a/src/zm_thread.h +++ b/src/zm_thread.h @@ -20,9 +20,12 @@ #ifndef ZM_THREAD_H #define ZM_THREAD_H +class RecursiveMutex; + + +#include "zm_config.h" #include #include -#include #ifdef HAVE_SYS_SYSCALL_H #include #endif // HAVE_SYS_SYSCALL_H