From 1fa13e57574a4dd3a06a3e7978e371a499879ca2 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Oct 2018 13:10:54 -0400 Subject: [PATCH 1/9] Add SWRESAMPLE libs --- CMakeLists.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d070c6d3..e49686ef1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -602,7 +602,7 @@ if(NOT ZM_NO_FFMPEG) set(optlibsnotfound "${optlibsnotfound} SWScale") endif(SWSCALE_LIBRARIES) - # rescale (using find_library and find_path) + # AVresample (using find_library and find_path) find_library(AVRESAMPLE_LIBRARIES avresample) if(AVRESAMPLE_LIBRARIES) set(HAVE_LIBAVRESAMPLE 1) @@ -619,6 +619,23 @@ if(NOT ZM_NO_FFMPEG) set(optlibsnotfound "${optlibsnotfound} AVResample") endif(AVRESAMPLE_LIBRARIES) + # SWresample (using find_library and find_path) + find_library(SWRESAMPLE_LIBRARIES swresample) + if(SWRESAMPLE_LIBRARIES) + set(HAVE_LIBSWRESAMPLE 1) + list(APPEND ZM_BIN_LIBS "${SWRESAMPLE_LIBRARIES}") + find_path(SWRESAMPLE_INCLUDE_DIR "libswresample/swresample.h" /usr/include/ffmpeg) + if(SWRESAMPLE_INCLUDE_DIR) + include_directories("${SWRESAMPLE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${SWRESAMPLE_INCLUDE_DIR}") + endif(SWRESAMPLE_INCLUDE_DIR) + mark_as_advanced(FORCE SWRESAMPLE_LIBRARIES SWRESAMPLE_INCLUDE_DIR) + check_include_file("libswresample/swresample.h" HAVE_LIBSWRESAMPLE_SWRESAMPLE_H) + set(optlibsfound "${optlibsfound} SWResample") + else(SWRESAMPLE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} SWResample") + endif(SWRESAMPLE_LIBRARIES) + # Find the path to the ffmpeg executable find_program(FFMPEG_EXECUTABLE NAMES ffmpeg avconv From 5a6e700c456176fe2eedc4065caaf9725caae00a Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Fri, 14 Dec 2018 20:27:12 -0600 Subject: [PATCH 2/9] rpm packaging - update fcgiwrap socket location I pushed a new fgciwrap package to Fedora and the socket file in the package is in a different location. See: https://bugzilla.redhat.com/show_bug.cgi?id=1655281 --- distros/redhat/nginx/zoneminder.nginx.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/redhat/nginx/zoneminder.nginx.conf.in b/distros/redhat/nginx/zoneminder.nginx.conf.in index c2e3edee7..2976a83b2 100644 --- a/distros/redhat/nginx/zoneminder.nginx.conf.in +++ b/distros/redhat/nginx/zoneminder.nginx.conf.in @@ -21,7 +21,7 @@ server { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; - fastcgi_pass unix:/run/fcgiwrap.sock; + fastcgi_pass unix:/run/fcgiwrap/fcgiwrap-nginx.sock; } location /zm/cache { From c1f46a9cb03bad6efc5ad24e6911b953dfdd9eab Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 15 Dec 2018 16:29:44 -0600 Subject: [PATCH 3/9] Update README.httpd --- distros/redhat/readme/README.httpd | 5 ----- 1 file changed, 5 deletions(-) diff --git a/distros/redhat/readme/README.httpd b/distros/redhat/readme/README.httpd index cb5805b18..5301850df 100644 --- a/distros/redhat/readme/README.httpd +++ b/distros/redhat/readme/README.httpd @@ -146,13 +146,8 @@ Upgrades See step 6 of the installation section if you have not already done this during a previous upgrade. -<<<<<<< HEAD - If this step is not performed correctly, the web console will appear - mostly empty and/or significantly corrupted post-upgrade. -======= IMPORTANT: Failure to complete this step properly will result in a mostly empty or significantly corrupted web console post-upgrade. ->>>>>>> 5b211d250910918782d20bf32b0e33a38a0df4dd 4. Upgrade the database before starting ZoneMinder. From 622c17f628acbe11c58341a5bcf5af5ce2a728f5 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sun, 16 Dec 2018 11:02:07 -0500 Subject: [PATCH 4/9] make sure auth is regenerated each time we call this API (#2347) --- web/api/app/Controller/HostController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php index d4e19fd77..ce101c73d 100644 --- a/web/api/app/Controller/HostController.php +++ b/web/api/app/Controller/HostController.php @@ -71,7 +71,8 @@ class HostController extends AppController { $zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value']; if ( $zmAuthRelay == 'hashed' ) { $zmAuthHashIps = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value']; - $credentials = 'auth='.generateAuthHash($zmAuthHashIps); + // make sure auth is regenerated each time we call this API + $credentials = 'auth='.generateAuthHash($zmAuthHashIps,true); } else { // user will need to append the store password here $credentials = 'user='.$this->Session->read('user.Username').'&pass='; From 62ce3c1f65de815639ac53035e10298340641dba Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Dec 2018 13:38:11 -0500 Subject: [PATCH 5/9] Implement libswresample in place of libavresample which is deprecated --- src/zm_videostore.cpp | 125 ++++++++++++++++++++++++++++-------------- src/zm_videostore.h | 12 +++- 2 files changed, 93 insertions(+), 44 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 746036efe..31916bdab 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -205,7 +205,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, audio_out_stream = NULL; in_frame = NULL; out_frame = NULL; -#ifdef HAVE_LIBAVRESAMPLE +#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE) resample_ctx = NULL; #endif @@ -220,7 +220,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, audio_in_ctx = audio_in_stream->codec; #endif - if (audio_in_ctx->codec_id != AV_CODEC_ID_AAC) { + if ( audio_in_ctx->codec_id != AV_CODEC_ID_AAC ) { static char error_buffer[256]; avcodec_string(error_buffer, sizeof(error_buffer), audio_in_ctx, 0); Debug(2, "Got something other than AAC (%s)", error_buffer); @@ -241,8 +241,6 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in, Error("Unable to create audio out stream"); audio_out_stream = NULL; } else { - Debug(2, "setting parameters"); - #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) audio_out_ctx = avcodec_alloc_context3(audio_out_codec); // Copy params from instream to ctx @@ -466,10 +464,16 @@ VideoStore::~VideoStore() { avcodec_free_context(&audio_out_ctx); #endif audio_out_ctx = NULL; -#ifdef HAVE_LIBAVRESAMPLE +#if defined(HAVE_LIBAVRESAMPLE) || defined(HAVE_LIBSWRESAMPLE) if ( resample_ctx ) { +#if defined(HAVE_LIBSWRESAMPLE) + swr_free(&resample_ctx); +#else +#if defined(HAVE_LIBAVRESAMPLE) avresample_close(resample_ctx); avresample_free(&resample_ctx); +#endif +#endif } if ( in_frame ) { av_frame_free(&in_frame); @@ -491,7 +495,12 @@ VideoStore::~VideoStore() { } // VideoStore::~VideoStore() bool VideoStore::setup_resampler() { -#ifdef HAVE_LIBAVRESAMPLE +#if !defined(HAVE_LIBSWRESAMPLE) && !defined(HAVE_LIBAVRESAMPLE) + Error( + "Not built with resample library. " + "Cannot do audio conversion to AAC"); + return false; +#else #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) // Newer ffmpeg wants to keep everything separate... so have to lookup our own @@ -499,8 +508,7 @@ bool VideoStore::setup_resampler() { audio_in_codec = avcodec_find_decoder(audio_in_stream->codecpar->codec_id); #else - audio_in_codec = - avcodec_find_decoder(audio_in_ctx->codec_id); + audio_in_codec = avcodec_find_decoder(audio_in_ctx->codec_id); #endif ret = avcodec_open2(audio_in_ctx, audio_in_codec, NULL); if ( ret < 0 ) { @@ -531,6 +539,9 @@ bool VideoStore::setup_resampler() { audio_out_stream = avformat_new_stream(oc, NULL); audio_out_ctx = audio_out_stream->codec; #endif + // Some formats (i.e. WAV) do not produce the proper channel layout + if ( audio_in_ctx->channel_layout == 0 ) + audio_in_ctx->channel_layout = av_get_channel_layout("mono"); /* put sample parameters */ audio_out_ctx->bit_rate = audio_in_ctx->bit_rate; @@ -622,40 +633,55 @@ bool VideoStore::setup_resampler() { return false; } +#if defined(HAVE_LIBSWRESAMPLE) + resample_ctx = swr_alloc_set_opts(NULL, + av_get_default_channel_layout(audio_out_ctx->channels), + audio_out_ctx->sample_fmt, + audio_out_ctx->sample_rate, + av_get_default_channel_layout(audio_in_ctx->channels), + audio_in_ctx->sample_fmt, + audio_in_ctx->sample_rate, + 0, NULL); + if ( !resample_ctx ) { + Error("Could not allocate resample context"); + av_frame_free(&in_frame); + av_frame_free(&out_frame); + return false; + } + if ( (ret = swr_init(resample_ctx)) < 0 ) { + Error("Could not open resampler"); + av_frame_free(&in_frame); + av_frame_free(&out_frame); + swr_free(&resample_ctx); + return false; + } +#else +#if defined(HAVE_LIBAVRESAMPLE) // Setup the audio resampler resample_ctx = avresample_alloc_context(); if ( !resample_ctx ) { Error("Could not allocate resample ctx"); + av_frame_free(&in_frame); + av_frame_free(&out_frame); return false; } - // Some formats (i.e. WAV) do not produce the proper channel layout - uint64_t layout = av_get_channel_layout("mono"); - if ( audio_in_ctx->channel_layout == 0 ) { - av_opt_set_int(resample_ctx, "in_channel_layout", layout, 0); - Debug(1, "Bad in channel layout. Need to set it to mono (%d).", layout); - } else { - av_opt_set_int(resample_ctx, "in_channel_layout", - audio_in_ctx->channel_layout, 0); - layout = audio_in_ctx->channel_layout; - } - + av_opt_set_int(resample_ctx, "in_channel_layout", + audio_in_ctx->channel_layout, 0); av_opt_set_int(resample_ctx, "in_sample_fmt", - audio_in_ctx->sample_fmt, 0); + audio_in_ctx->sample_fmt, 0); av_opt_set_int(resample_ctx, "in_sample_rate", - audio_in_ctx->sample_rate, 0); - av_opt_set_int(resample_ctx, "in_channels", audio_in_ctx->channels, - 0); - // av_opt_set_int( resample_ctx, "out_channel_layout", - // audio_out_ctx->channel_layout, 0); + audio_in_ctx->sample_rate, 0); + av_opt_set_int(resample_ctx, "in_channels", + audio_in_ctx->channels, 0); av_opt_set_int(resample_ctx, "out_channel_layout", - layout, 0); + audio_in_ctx->channel_layout, 0); av_opt_set_int(resample_ctx, "out_sample_fmt", - audio_out_ctx->sample_fmt, 0); + audio_out_ctx->sample_fmt, 0); av_opt_set_int(resample_ctx, "out_sample_rate", - audio_out_ctx->sample_rate, 0); + audio_out_ctx->sample_rate, 0); av_opt_set_int(resample_ctx, "out_channels", - audio_out_ctx->channels, 0); + audio_out_ctx->channels, 0); ret = avresample_open(resample_ctx); if ( ret < 0 ) { @@ -664,6 +690,8 @@ bool VideoStore::setup_resampler() { } else { Debug(2, "Success opening resampler"); } +#endif +#endif out_frame->nb_samples = audio_out_ctx->frame_size; out_frame->format = audio_out_ctx->sample_fmt; @@ -694,11 +722,6 @@ bool VideoStore::setup_resampler() { } return true; -#else - Error( - "Not built with libavresample library. Cannot do audio conversion to " - "AAC"); - return false; #endif } // end bool VideoStore::setup_resampler() @@ -858,9 +881,9 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { if ( audio_out_codec ) { Debug(3, "Have audio codec"); -#ifdef HAVE_LIBAVRESAMPLE +#if defined(HAVE_LIBSWRESAMPLE) || defined(HAVE_LIBAVRESAMPLE) -#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) + #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) ret = avcodec_send_packet(audio_in_ctx, ipkt); if ( ret < 0 ) { Error("avcodec_send_packet fail %s", av_make_error_string(ret).c_str()); @@ -877,7 +900,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { "layout(%d)", in_frame->nb_samples, in_frame->format, in_frame->sample_rate, in_frame->channel_layout); -#else + #else /** * Decode the audio frame stored in the packet. * The in audio stream decoder is used to do this. @@ -897,11 +920,24 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { Debug(2, "Not ready to transcode a frame yet."); return 0; } -#endif + #endif int frame_size = out_frame->nb_samples; // Resample the in into the audioSampleBuffer until we proceed the whole // decoded data + #if defined(HAVE_LIBSWRESAMPLE) + Debug(2, "Converting %d to %d samples", in_frame->nb_samples, out_frame->nb_samples); + if ((ret = swr_convert(resample_ctx, + out_frame->data, frame_size, + (const uint8_t**)in_frame->data, + in_frame->nb_samples)) < 0) { + Error("Could not resample frame (error '%s')\n", + av_make_error_string(ret).c_str()); + av_frame_unref(in_frame); + return 0; + } + #else + #if defined(HAVE_LIBAVRESAMPLE) if ((ret = avresample_convert(resample_ctx, NULL, 0, 0, in_frame->data, 0, in_frame->nb_samples)) < 0) { @@ -910,8 +946,11 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { av_frame_unref(in_frame); return 0; } + #endif + #endif av_frame_unref(in_frame); + #if defined(HAVE_LIBAVRESAMPLE) int samples_available = avresample_available(resample_ctx); if (samples_available < frame_size) { @@ -926,6 +965,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { Warning("Error reading resampled audio: "); return 0; } + #endif Debug(2, "Frame: samples(%d), format(%d), sample_rate(%d), channel layout(%d)", out_frame->nb_samples, out_frame->format, @@ -934,7 +974,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { av_init_packet(&opkt); Debug(5, "after init packet"); -#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) + #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0) if ((ret = avcodec_send_frame(audio_out_ctx, out_frame)) < 0) { Error("Could not send frame (error '%s')", av_make_error_string(ret).c_str()); @@ -958,7 +998,7 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { // av_frame_unref( out_frame ); return 0; } -#else + #else if ((ret = avcodec_encode_audio2(audio_out_ctx, &opkt, out_frame, &data_present)) < 0) { Error("Could not encode frame (error '%s')", @@ -971,8 +1011,9 @@ int VideoStore::writeAudioFramePacket(AVPacket *ipkt) { zm_av_packet_unref(&opkt); return 0; } -#endif - + #endif +#else + Error("Have audio codec but no resampler?!"); #endif } else { av_init_packet(&opkt); diff --git a/src/zm_videostore.h b/src/zm_videostore.h index 282d96da7..bc7cd8417 100644 --- a/src/zm_videostore.h +++ b/src/zm_videostore.h @@ -3,8 +3,12 @@ #include "zm_ffmpeg.h" extern "C" { -#ifdef HAVE_LIBAVRESAMPLE -#include "libavresample/avresample.h" +#ifdef HAVE_LIBSWRESAMPLE + #include "libswresample/swresample.h" +#else + #ifdef HAVE_LIBAVRESAMPLE + #include "libavresample/avresample.h" + #endif #endif } @@ -38,8 +42,12 @@ private: // The following are used when encoding the audio stream to AAC AVCodec *audio_out_codec; AVCodecContext *audio_out_ctx; +#ifdef HAVE_LIBSWRESAMPLE + SwrContext *resample_ctx; +#else #ifdef HAVE_LIBAVRESAMPLE AVAudioResampleContext* resample_ctx; +#endif #endif uint8_t *converted_in_samples; From 53c66e44dbe2ec0a50f289ed2920e35505495f8f Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Dec 2018 13:38:24 -0500 Subject: [PATCH 6/9] Implement libswresample in place of libavresample which is deprecated --- CMakeLists.txt | 35 ++++++++++++++++++----------------- zoneminder-config.cmake | 2 ++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef8afc91e..a0d037099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,23 +607,6 @@ if(NOT ZM_NO_FFMPEG) set(optlibsnotfound "${optlibsnotfound} SWScale") endif(SWSCALE_LIBRARIES) - # AVresample (using find_library and find_path) - find_library(AVRESAMPLE_LIBRARIES avresample) - if(AVRESAMPLE_LIBRARIES) - set(HAVE_LIBAVRESAMPLE 1) - list(APPEND ZM_BIN_LIBS "${AVRESAMPLE_LIBRARIES}") - find_path(AVRESAMPLE_INCLUDE_DIR "libavresample/avresample.h" /usr/include/ffmpeg) - if(AVRESAMPLE_INCLUDE_DIR) - include_directories("${AVRESAMPLE_INCLUDE_DIR}") - set(CMAKE_REQUIRED_INCLUDES "${AVRESAMPLE_INCLUDE_DIR}") - endif(AVRESAMPLE_INCLUDE_DIR) - mark_as_advanced(FORCE AVRESAMPLE_LIBRARIES AVRESAMPLE_INCLUDE_DIR) - check_include_file("libavresample/avresample.h" HAVE_LIBAVRESAMPLE_AVRESAMPLE_H) - set(optlibsfound "${optlibsfound} AVResample") - else(AVRESAMPLE_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVResample") - endif(AVRESAMPLE_LIBRARIES) - # SWresample (using find_library and find_path) find_library(SWRESAMPLE_LIBRARIES swresample) if(SWRESAMPLE_LIBRARIES) @@ -639,6 +622,24 @@ if(NOT ZM_NO_FFMPEG) set(optlibsfound "${optlibsfound} SWResample") else(SWRESAMPLE_LIBRARIES) set(optlibsnotfound "${optlibsnotfound} SWResample") + + # AVresample (using find_library and find_path) + find_library(AVRESAMPLE_LIBRARIES avresample) + if(AVRESAMPLE_LIBRARIES) + set(HAVE_LIBAVRESAMPLE 1) + list(APPEND ZM_BIN_LIBS "${AVRESAMPLE_LIBRARIES}") + find_path(AVRESAMPLE_INCLUDE_DIR "libavresample/avresample.h" /usr/include/ffmpeg) + if(AVRESAMPLE_INCLUDE_DIR) + include_directories("${AVRESAMPLE_INCLUDE_DIR}") + set(CMAKE_REQUIRED_INCLUDES "${AVRESAMPLE_INCLUDE_DIR}") + endif(AVRESAMPLE_INCLUDE_DIR) + mark_as_advanced(FORCE AVRESAMPLE_LIBRARIES AVRESAMPLE_INCLUDE_DIR) + check_include_file("libavresample/avresample.h" HAVE_LIBAVRESAMPLE_AVRESAMPLE_H) + set(optlibsfound "${optlibsfound} AVResample") + else(AVRESAMPLE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVResample") + endif(AVRESAMPLE_LIBRARIES) + endif(SWRESAMPLE_LIBRARIES) # Find the path to the ffmpeg executable diff --git a/zoneminder-config.cmake b/zoneminder-config.cmake index 8641bb4a8..e088e68dc 100644 --- a/zoneminder-config.cmake +++ b/zoneminder-config.cmake @@ -54,6 +54,8 @@ #cmakedefine HAVE_LIBAVUTIL_HWCONTEXT_H 0 #cmakedefine HAVE_LIBSWSCALE 1 #cmakedefine HAVE_LIBSWSCALE_SWSCALE_H 1 +#cmakedefine HAVE_LIBSWRESAMPLE 1 +#cmakedefine HAVE_LIBSWRESAMPLE_SWRESAMPLE_H 1 #cmakedefine HAVE_LIBAVRESAMPLE 1 #cmakedefine HAVE_LIBAVRESAMPLE_AVRESAMPLE_H 1 #cmakedefine HAVE_LIBVLC 1 From 3f1e49587270ba19d8fb4accb93f0ad2cae3abec Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Dec 2018 13:41:09 -0500 Subject: [PATCH 7/9] Add libswresample to dependencies --- distros/ubuntu1604/control | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/distros/ubuntu1604/control b/distros/ubuntu1604/control index 991ed9e54..d91fd4f53 100644 --- a/distros/ubuntu1604/control +++ b/distros/ubuntu1604/control @@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apa ,libavcodec-dev (>= 6:10~) ,libavformat-dev (>= 6:10~) ,libavutil-dev (>= 6:10~) + ,libswresample-dev ,libswscale-dev (>= 6:10~) ,ffmpeg | libav-tools ,net-tools @@ -41,7 +42,9 @@ Package: zoneminder Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends} ,javascript-common - ,libmp4v2-2, libx264-142|libx264-148|libx264-152, libswscale-ffmpeg3|libswscale4|libswscale3|libswscale5 + ,libmp4v2-2, libx264-142|libx264-148|libx264-152 + ,libswscale-ffmpeg3|libswscale4|libswscale3|libswscale5 + ,libswresample2|libswresample3|libswresample24 ,ffmpeg | libav-tools ,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl ,libdbd-mysql-perl From 1d371b7a177c1dcb9ecceb11d9d2190e1904ff7d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Dec 2018 13:41:57 -0500 Subject: [PATCH 8/9] Fix small memleak of linked_monitors not getting freed on Monitor destruction. Fix unlocking db mutex before logging --- src/zm_monitor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 9f2d92102..5a513dbf8 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -626,6 +626,13 @@ Debug(3, "Success connecting"); } Monitor::~Monitor() { + if ( n_linked_monitors ) { + for( int i = 0; i < n_linked_monitors; i++ ) { + delete linked_monitors[i]; + } + delete[] linked_monitors; + linked_monitors = 0; + } if ( timestamps ) { delete[] timestamps; timestamps = 0; @@ -1906,15 +1913,15 @@ void Monitor::ReloadLinkedMonitors(const char *p_linked_monitors) { static char sql[ZM_SQL_SML_BUFSIZ]; snprintf(sql, sizeof(sql), "select Id, Name from Monitors where Id = %d and Function != 'None' and Function != 'Monitor' and Enabled = 1", link_ids[i] ); if ( mysql_query(&dbconn, sql) ) { - Error("Can't run query: %s", mysql_error(&dbconn)); db_mutex.unlock(); + Error("Can't run query: %s", mysql_error(&dbconn)); continue; } MYSQL_RES *result = mysql_store_result(&dbconn); if ( !result ) { - Error("Can't use query result: %s", mysql_error(&dbconn)); db_mutex.unlock(); + Error("Can't use query result: %s", mysql_error(&dbconn)); continue; } db_mutex.unlock(); From 0c096160596530cbae4ba6c89562e9da328ddcc5 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 20 Dec 2018 13:58:09 -0500 Subject: [PATCH 9/9] put back privacy notice update --- scripts/zmupdate.pl.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/zmupdate.pl.in b/scripts/zmupdate.pl.in index bb9dddac4..8517e0277 100644 --- a/scripts/zmupdate.pl.in +++ b/scripts/zmupdate.pl.in @@ -923,10 +923,10 @@ if ( $version ) { die( "Can't find upgrade from version '$version'" ); } # Re-enable the privacy popup after each upgrade - #my $sql = "update Config set Value = 1 where Name = 'ZM_SHOW_PRIVACY'"; - #my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); - #my $res = $sth->execute( ) or die( "Can't execute: ".$sth->errstr() ); - #$sth->finish(); + my $sql = "update Config set Value = 1 where Name = 'ZM_SHOW_PRIVACY'"; + my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); + my $res = $sth->execute( ) or die( "Can't execute: ".$sth->errstr() ); + $sth->finish(); print( "\nDatabase upgrade to version ".ZM_VERSION." successful.\n\n" ); } zmDbDisconnect();