app-admin/syslog-ng: fix daemon crashes on x86
authorTomas Mozes <hydrapolic@gmail.com>
Fri, 20 Sep 2019 13:10:20 +0000 (13:10 +0000)
committerJoonas Niilola <juippis@gentoo.org>
Fri, 20 Sep 2019 15:42:39 +0000 (18:42 +0300)
Signed-off-by: Tomáš Mózes <hydrapolic@gmail.com>
Closes: https://bugs.gentoo.org/695176
Signed-off-by: Joonas Niilola <juippis@gentoo.org>
app-admin/syslog-ng/files/patches/syslog-ng-3.23.1-fix-sigabrt.patch [new file with mode: 0644]
app-admin/syslog-ng/syslog-ng-3.23.1-r1.ebuild [moved from app-admin/syslog-ng/syslog-ng-3.23.1.ebuild with 98% similarity]

diff --git a/app-admin/syslog-ng/files/patches/syslog-ng-3.23.1-fix-sigabrt.patch b/app-admin/syslog-ng/files/patches/syslog-ng-3.23.1-fix-sigabrt.patch
new file mode 100644 (file)
index 0000000..6d27e88
--- /dev/null
@@ -0,0 +1,72 @@
+diff --git a/lib/logsource.c b/lib/logsource.c
+index 3f38b66e8b..83c61a8e93 100644
+--- a/lib/logsource.c
++++ b/lib/logsource.c
+@@ -633,7 +633,20 @@ log_source_queue(LogPipe *s, LogMessage *msg, const LogPathOptions *path_options
+                   evt_tag_printf("msg", "%p", msg));
+   msg_set_context(NULL);
++}
++
++static void
++_initialize_window(LogSource *self, gint init_window_size)
++{
++  self->window_initialized = TRUE;
++  window_size_counter_set(&self->window_size, init_window_size);
++  self->full_window_size = init_window_size;
++}
++static gboolean
++_is_window_initialized(LogSource *self)
++{
++  return self->window_initialized;
+ }
+ void
+@@ -645,11 +658,9 @@ log_source_set_options(LogSource *self, LogSourceOptions *options,
+    * configuration and we received a SIGHUP.  This means that opened
+    * connections will not have their window_size changed. */
+-  if ((gint)window_size_counter_get(&self->window_size, NULL) == -1)
+-    {
+-      window_size_counter_set(&self->window_size, options->init_window_size);
+-      self->full_window_size = options->init_window_size;
+-    }
++  if (!_is_window_initialized(self))
++    _initialize_window(self, options->init_window_size);
++
+   self->options = options;
+   if (self->stats_id)
+     g_free(self->stats_id);
+@@ -679,7 +690,7 @@ log_source_init_instance(LogSource *self, GlobalConfig *cfg)
+   self->super.free_fn = log_source_free;
+   self->super.init = log_source_init;
+   self->super.deinit = log_source_deinit;
+-  window_size_counter_set(&self->window_size, (gsize)-1);
++  self->window_initialized = FALSE;
+   self->ack_tracker = NULL;
+ }
+@@ -696,7 +707,9 @@ log_source_free(LogPipe *s)
+   ack_tracker_free(self->ack_tracker);
+   self->ack_tracker = NULL;
+-  _release_dynamic_window(self);
++
++  if (G_UNLIKELY(dynamic_window_is_enabled(&self->dynamic_window)))
++    _release_dynamic_window(self);
+ }
+ void
+diff --git a/lib/logsource.h b/lib/logsource.h
+index 370842efc2..75d4926046 100644
+--- a/lib/logsource.h
++++ b/lib/logsource.h
+@@ -71,6 +71,7 @@ struct _LogSource
+   gchar *stats_instance;
+   WindowSizeCounter window_size;
+   DynamicWindow dynamic_window;
++  gboolean window_initialized;
+   /* full_window_size = static + dynamic */
+   gsize full_window_size;
+   atomic_gssize window_size_to_be_reclaimed;
similarity index 98%
rename from app-admin/syslog-ng/syslog-ng-3.23.1.ebuild
rename to app-admin/syslog-ng/syslog-ng-3.23.1-r1.ebuild
index 3cb8ad6b096ae4e0b710a546f45f14c3ea3b96b1..bc13ee0fdc7812403822d24437fdb543dfae15c1 100644 (file)
@@ -51,6 +51,9 @@ DOCS=( AUTHORS NEWS.md CONTRIBUTING.md contrib/syslog-ng.conf.{HP-UX,RedHat,SunO
        contrib/syslog2ng "${T}/syslog-ng.conf.gentoo.hardened"
        "${T}/syslog-ng.logrotate.hardened" "${FILESDIR}/README.hardened" )
 
+# bug #695176
+PATCHES=( "${FILESDIR}/patches/${PN}-3.23.1-fix-sigabrt.patch" )
+
 pkg_setup() {
        use python && python-single-r1_pkg_setup
 }