Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libqb for openSUSE:Factory checked 
in at 2021-10-11 16:48:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libqb (Old)
 and      /work/SRC/openSUSE:Factory/.libqb.new.2443 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libqb"

Mon Oct 11 16:48:41 2021 rev:30 rq:924180 version:2.0.3+20210303.404adbc

Changes:
--------
--- /work/SRC/openSUSE:Factory/libqb/libqb.changes      2020-12-09 
22:11:10.531052088 +0100
+++ /work/SRC/openSUSE:Factory/.libqb.new.2443/libqb.changes    2021-10-11 
16:48:50.846189828 +0200
@@ -1,0 +2,11 @@
+Thu Oct 07 11:39:16 UTC 2021 - Yan Gao <y...@suse.com>
+
+- Update to version 2.0.3+20210303.404adbc (v2.0.3):
+- syslog: Add a message-id parameter for messages (gh#ClusterLabs/libqb#433)
+- timers: Add some locking (gh#ClusterLabs/libqb#436)
+- ipcc: Have a few goes at tidying up after a dead server 
(gh#ClusterLabs/libqb#434)
+- strlcpy: Check for maxlen underflow (gh#ClusterLabs/libqb#432)
+- doxygen2man: fix printing of lines starting with '.' 
(gh#ClusterLabs/libqb#431)
+- doxygen2man: ignore all-whitespace brief descriptions 
(gh#ClusterLabs/libqb#430)
+
+-------------------------------------------------------------------

Old:
----
  libqb-2.0.2+20201203.def947e.tar.xz

New:
----
  libqb-2.0.3+20210303.404adbc.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libqb.spec ++++++
--- /var/tmp/diff_new_pack.lwK2EH/_old  2021-10-11 16:48:51.334190604 +0200
+++ /var/tmp/diff_new_pack.lwK2EH/_new  2021-10-11 16:48:51.338190610 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package libqb
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -21,7 +21,7 @@
 %bcond_without doxygen2man
 
 Name:           libqb
-Version:        2.0.2+20201203.def947e
+Version:        2.0.3+20210303.404adbc
 Release:        0
 Summary:        An IPC library for high performance servers
 License:        LGPL-2.1-or-later

++++++ _service ++++++
--- /var/tmp/diff_new_pack.lwK2EH/_old  2021-10-11 16:48:51.370190661 +0200
+++ /var/tmp/diff_new_pack.lwK2EH/_new  2021-10-11 16:48:51.370190661 +0200
@@ -8,10 +8,10 @@
     To update to a new release, change "revision" to the desired
     git commit hash and bump "version" if necessary
 
-    <param name="version">2.0.2</param>
+    <param name="version">2.0.3</param>
 -->
-    <param name="versionformat">2.0.2+%cd.%h</param>
-    <param name="revision">master</param>
+    <param name="versionformat">2.0.3+%cd.%h</param>
+    <param name="revision">v2.0.3</param>
     <param name="changesgenerate">enable</param>
   </service>
 

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.lwK2EH/_old  2021-10-11 16:48:51.386190686 +0200
+++ /var/tmp/diff_new_pack.lwK2EH/_new  2021-10-11 16:48:51.386190686 +0200
@@ -1,6 +1,6 @@
 <servicedata>
   <service name="tar_scm">
     <param name="url">git://github.com/ClusterLabs/libqb.git</param>
-    <param 
name="changesrevision">def947efcf9cbfa05b10aada8cc32353e0f82052</param>
+    <param 
name="changesrevision">404adbcd998ec83643e47d92b3ea8d9c3970e68b</param>
   </service>
 </servicedata>
\ No newline at end of file

++++++ libqb-2.0.2+20201203.def947e.tar.xz -> 
libqb-2.0.3+20210303.404adbc.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libqb-2.0.2+20201203.def947e/doxygen2man/doxygen2man.c 
new/libqb-2.0.3+20210303.404adbc/doxygen2man/doxygen2man.c
--- old/libqb-2.0.2+20201203.def947e/doxygen2man/doxygen2man.c  2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/doxygen2man/doxygen2man.c  2021-03-03 
09:32:09.000000000 +0100
@@ -222,7 +222,14 @@
                        buffer = cstring_append_chars(buffer, " ");
                }
                if (strcmp((char*)sub_tag->name, "text") == 0) {
-                       buffer = cstring_append_chars(buffer, 
(char*)sub_tag->content);
+                       // If the line starts with a dot then escape the first 
one to
+                       // stop nroff thinking it's a macro
+                       char *tmp = (char*)sub_tag->content;
+                       if (tmp[0] == '.') {
+                               buffer = cstring_append_chars(buffer, 
(char*)"\\[char46]");
+                               tmp += 1;
+                       }
+                       buffer = cstring_append_chars(buffer, tmp);
                }
                if (strcmp((char*)sub_tag->name, "ref") == 0) {
                        // Handled by the child recusion below
@@ -756,7 +763,7 @@
        fprintf(manfile, ".TH %s %s %s \"%s\" \"%s\"\n", allcaps(name), 
man_section, dateptr, package_name, header);
 
        fprintf(manfile, ".SH NAME\n");
-       if (brief) {
+       if (brief && not_all_whitespace(brief)) {
                fprintf(manfile, "%s \\- %s\n", name, brief);
        } else {
                fprintf(manfile, "%s\n", name);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/include/qb/qblog.h 
new/libqb-2.0.3+20210303.404adbc/include/qb/qblog.h
--- old/libqb-2.0.2+20201203.def947e/include/qb/qblog.h 2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/include/qb/qblog.h 2021-03-03 
09:32:09.000000000 +0100
@@ -249,6 +249,7 @@
 
 /**
  * An instance of this structure is created for each log message
+ * with the message-id
  */
 struct qb_log_callsite {
        const char *function;
@@ -258,6 +259,7 @@
        uint32_t lineno;
        uint32_t targets;
        uint32_t tags;
+       const char *message_id;
 } __attribute__((aligned(8)));
 
 typedef void (*qb_log_filter_fn)(struct qb_log_callsite * cs);
@@ -319,6 +321,39 @@
                                            uint32_t lineno,
                                            uint32_t tags);
 
+/**
+ * Get or create a callsite at the given position.
+ * The same that qb_log_callsite_get but with the
+ * message_id parameter.
+ *
+ * The result can then be passed into qb_log_real_()
+ *
+ * @param message_id in the systemd catalog or NULL
+ * @param function originating function name
+ * @param filename originating filename
+ * @param format format string
+ * @param priority this takes syslog priorities.
+ * @param lineno file line number
+ * @param tags the tag
+ */
+struct qb_log_callsite* qb_log_callsite_get2(const char *message_id,
+                                           const char *function,
+                                           const char *filename,
+                                           const char *format,
+                                           uint8_t priority,
+                                           uint32_t lineno,
+                                           uint32_t tags);
+
+void qb_log_from_external_source_va2(const char *message_id,
+                                   const char *function,
+                                   const char *filename,
+                                   const char *format,
+                                   uint8_t priority,
+                                   uint32_t lineno,
+                                   uint32_t tags,
+                                   va_list ap)
+       __attribute__ ((format (printf, 4, 0)));
+
 void qb_log_from_external_source_va(const char *function,
                                    const char *filename,
                                    const char *format,
@@ -332,6 +367,7 @@
  * This is the function to generate a log message if you want to
  * manually add tags.
  *
+ * @param message_id in the systemd catalog or NULL
  * @param priority this takes syslog priorities.
  * @param tags this is a uint32_t that you can use with
  *             qb_log_tags_stringify_fn_set() to "tag" a log message
@@ -340,13 +376,37 @@
  * @param fmt usual printf style format specifiers
  * @param args usual printf style args
  */
-#define qb_logt(priority, tags, fmt, args...) do {     \
+#define qb_logt2(message_id, priority, tags, fmt, args...) do {        \
        struct qb_log_callsite* descriptor_pt =         \
-       qb_log_callsite_get(__func__, __FILE__, fmt,    \
+       qb_log_callsite_get2(message_id, __func__, __FILE__, fmt,       \
                            priority, __LINE__, tags);  \
        qb_log_real_(descriptor_pt, ##args);            \
     } while(0)
 
+/**
+ * This is the function to generate a log message if you want to
+ * manually add tags.
+ *
+ * @param priority this takes syslog priorities.
+ * @param tags this is a uint32_t that you can use with
+ *             qb_log_tags_stringify_fn_set() to "tag" a log message
+ *             with a feature or sub-system then you can use "%g"
+ *             in the format specifer to print it out.
+ * @param fmt usual printf style format specifiers
+ * @param args usual printf style args
+ */
+#define qb_logt(priority, tags, fmt, args...) qb_logt2(NULL, priority, tags, 
fmt, ##args)
+
+
+/**
+ * This is the main function to generate a log message.
+ *
+ * @param message_id in the systemd catalog or NULL
+ * @param priority this takes syslog priorities.
+ * @param fmt usual printf style format specifiers
+ * @param args usual printf style args
+ */
+#define qb_log2(message_id, priority, fmt, args...) qb_logt2(message_id, 
priority, 0, fmt, ##args)
 
 /**
  * This is the main function to generate a log message.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/include/tlist.h 
new/libqb-2.0.3+20210303.404adbc/include/tlist.h
--- old/libqb-2.0.2+20201203.def947e/include/tlist.h    2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/include/tlist.h    2021-03-03 
09:32:09.000000000 +0100
@@ -36,6 +36,7 @@
 
 struct timerlist {
        struct qb_list_head timer_head;
+       pthread_mutex_t list_mutex;
 };
 
 struct timerlist_timer {
@@ -50,16 +51,20 @@
 static inline void timerlist_init(struct timerlist *timerlist)
 {
        qb_list_init(&timerlist->timer_head);
+       pthread_mutex_init(&timerlist->list_mutex, NULL);
        timerlist_hertz = qb_util_nano_monotonic_hz();
 }
 
-static inline void timerlist_add(struct timerlist *timerlist,
+static inline int32_t timerlist_add(struct timerlist *timerlist,
                                 struct timerlist_timer *timer)
 {
        struct qb_list_head *timer_list = 0;
        struct timerlist_timer *timer_from_list;
        int32_t found = QB_FALSE;
 
+       if (pthread_mutex_lock(&timerlist->list_mutex)) {
+               return -errno;
+       }
        qb_list_for_each(timer_list, &timerlist->timer_head) {
 
                timer_from_list = qb_list_entry(timer_list,
@@ -74,6 +79,8 @@
        if (found == QB_FALSE) {
                qb_list_add_tail(&timer->list, &timerlist->timer_head);
        }
+       pthread_mutex_unlock(&timerlist->list_mutex);
+       return 0;
 }
 
 static inline int32_t timerlist_add_duration(struct timerlist *timerlist,
@@ -82,6 +89,7 @@
                                         uint64_t nano_duration,
                                         timer_handle * handle)
 {
+       int res;
        struct timerlist_timer *timer;
 
        timer =
@@ -95,7 +103,11 @@
        timer->data = data;
        timer->timer_fn = timer_fn;
        timer->handle_addr = handle;
-       timerlist_add(timerlist, timer);
+       res = timerlist_add(timerlist, timer);
+       if (res) {
+               free(timer);
+               return res;
+       }
 
        *handle = timer;
        return (0);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/Makefile.am 
new/libqb-2.0.3+20210303.404adbc/lib/Makefile.am
--- old/libqb-2.0.2+20201203.def947e/lib/Makefile.am    2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/Makefile.am    2021-03-03 
09:32:09.000000000 +0100
@@ -30,7 +30,7 @@
 
 lib_LTLIBRARIES                = libqb.la
 
-libqb_la_LDFLAGS       = -version-info 101:0:1
+libqb_la_LDFLAGS       = -version-info 102:0:2
 
 source_to_lint         = util.c hdb.c ringbuffer.c ringbuffer_helper.c \
                          array.c loop.c loop_poll.c loop_job.c \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/ipc_shm.c 
new/libqb-2.0.3+20210303.404adbc/lib/ipc_shm.c
--- old/libqb-2.0.2+20201203.def947e/lib/ipc_shm.c      2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/ipc_shm.c      2021-03-03 
09:32:09.000000000 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010-2021 Red Hat, Inc.
  *
  * Author: Angus Salkeld <asalk...@redhat.com>
  *
@@ -39,12 +39,43 @@
 qb_ipcc_shm_disconnect(struct qb_ipcc_connection *c)
 {
        void (*rb_destructor)(struct qb_ringbuffer_s *);
-
        rb_destructor = qb_rb_close;
-       if (!c->is_connected && (!c->server_pid || (kill(c->server_pid, 0) == 
-1 && errno == ESRCH))) {
+
+       /* This is an attempt to make sure that /dev/shm is cleaned up when a
+        * server exits unexpectedly. Normally it's the server's responsibility
+        * to tidy up sockets, but if it crashes or is killed with SIGKILL then
+        * the client (us) makes a reasonable attempt to tidy up the server 
sockets
+        * we have connected. The extra delay here just gives the server chance 
to
+        * disappear fully. As a client we can get here pretty quickly but 
shutting
+        * down a large server may take a little longer even when SIGKILLed.
+        * The 1/100th of a second is an arbitrary delay (of course) but seems 
to
+        * catch most servers in 2 tries or less.
+        */
+       if (!c->is_connected && c->server_pid) {
+               int attempt = 0;
+               while (attempt++ <= 3 && rb_destructor == qb_rb_close) {
+                       if (kill(c->server_pid, 0) == -1 && errno == ESRCH) {
+                               rb_destructor = qb_rb_force_close;
+                       } else {
+                               struct timespec ts = {0, 10*QB_TIME_NS_IN_MSEC};
+                               struct timespec ts_left = {0, 0};
+                               nanosleep(&ts, &ts_left);
+                       }
+               }
+       }
+       /*
+        * On FreeBSD we don't have a server PID so tidy up anyway. The
+        * server traps SIGBUS when cleaning up so will cope fine.
+        */
+       if (!c->is_connected && !c->server_pid) {
                rb_destructor = qb_rb_force_close;
        }
 
+       if (rb_destructor == qb_rb_force_close) {
+               qb_util_log(LOG_DEBUG,
+                           "FORCE closing server sockets\n");
+       }
+
        qb_ipcc_us_sock_close(c->setup.u.us.sock);
 
        rb_destructor(qb_rb_lastref_and_ret(&c->request.u.shm.rb));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/log.c 
new/libqb-2.0.3+20210303.404adbc/lib/log.c
--- old/libqb-2.0.2+20201203.def947e/lib/log.c  2020-12-03 14:05:43.000000000 
+0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/log.c  2021-03-03 09:32:09.000000000 
+0100
@@ -317,7 +317,8 @@
 }
 
 struct qb_log_callsite*
-qb_log_callsite_get(const char *function,
+qb_log_callsite_get2(const char *message_id,
+                   const char *function,
                    const char *filename,
                    const char *format,
                    uint8_t priority,
@@ -335,8 +336,9 @@
                return NULL;
        }
 
-       cs = qb_log_dcs_get(&new_dcs, function, filename,
-                           format, priority, lineno, tags);
+       cs = qb_log_dcs_get(&new_dcs, message_id, function, filename,
+                           format, priority, lineno, tags);
+
        if (cs == NULL) {
                return NULL;
        }
@@ -380,8 +382,21 @@
        return cs;
 }
 
+struct qb_log_callsite*
+qb_log_callsite_get(const char *function,
+                   const char *filename,
+                   const char *format,
+                   uint8_t priority,
+                   uint32_t lineno,
+                   uint32_t tags)
+{
+       return qb_log_callsite_get2(NULL, function, filename, format,
+                                   priority, lineno, tags);
+}
+
 void
-qb_log_from_external_source_va(const char *function,
+qb_log_from_external_source_va2(const char *message_id,
+                              const char *function,
                               const char *filename,
                               const char *format,
                               uint8_t priority,
@@ -393,12 +408,23 @@
                return;
        }
 
-       cs = qb_log_callsite_get(function, filename,
+       cs = qb_log_callsite_get2(message_id, function, filename,
                                 format, priority, lineno, tags);
        qb_log_real_va_(cs, ap);
 }
 
 void
+qb_log_from_external_source_va(const char *function,
+                              const char *filename,
+                              const char *format,
+                              uint8_t priority,
+                              uint32_t lineno, uint32_t tags, va_list ap)
+{
+       qb_log_from_external_source_va2(NULL, function, filename,
+                                  format, priority, lineno, tags, ap);
+}
+
+void
 qb_log_from_external_source(const char *function,
                            const char *filename,
                            const char *format,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/log_dcs.c 
new/libqb-2.0.3+20210303.404adbc/lib/log_dcs.c
--- old/libqb-2.0.2+20201203.def947e/lib/log_dcs.c      2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/log_dcs.c      2021-03-03 
09:32:09.000000000 +0100
@@ -58,7 +58,8 @@
 }
 
 static struct qb_log_callsite *
-_log_dcs_new_cs(const char *function,
+_log_dcs_new_cs(const char *message_id,
+               const char *function,
                const char *filename,
                const char *format,
                uint8_t priority, uint32_t lineno, uint32_t tags)
@@ -70,6 +71,7 @@
        assert(rc == 0);
        assert(cs != NULL);
 
+       cs->message_id = message_id ? strdup(message_id) : NULL;
        cs->function = strdup(function);
        cs->filename = strdup(filename);
        cs->format = strdup(format);
@@ -82,6 +84,7 @@
 
 struct qb_log_callsite *
 qb_log_dcs_get(int32_t * newly_created,
+              const char *message_id,
               const char *function,
               const char *filename,
               const char *format,
@@ -120,6 +123,7 @@
        (void)qb_thread_lock(arr_next_lock);
        if (csl_head->cs &&
                priority == csl_head->cs->priority &&
+               (message_id ? (strcmp(message_id, csl_head->cs->message_id) == 
0) : 1) &&
                strcmp(safe_filename, csl_head->cs->filename) == 0 &&
                strcmp(safe_format, csl_head->cs->format) == 0) {
                (void)qb_thread_unlock(arr_next_lock);
@@ -130,7 +134,8 @@
         * so we will either have to create it or go through a list
         */
        if (csl_head->cs == NULL) {
-               csl_head->cs = _log_dcs_new_cs(safe_function, safe_filename, 
safe_format,
+               csl_head->cs = _log_dcs_new_cs(message_id, safe_function,
+                                              safe_filename, safe_format,
                                               priority, lineno, tags);
                cs = csl_head->cs;
                csl_head->next = NULL;
@@ -152,7 +157,8 @@
                        if (csl == NULL) {
                                goto cleanup;
                        }
-                       csl->cs = _log_dcs_new_cs(safe_function, safe_filename, 
safe_format,
+                       csl->cs = _log_dcs_new_cs(message_id, safe_function,
+                                                 safe_filename, safe_format,
                                                  priority, lineno, tags);
                        csl->next = NULL;
                        csl_last->next = csl;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/log_int.h 
new/libqb-2.0.3+20210303.404adbc/lib/log_int.h
--- old/libqb-2.0.2+20201203.def947e/lib/log_int.h      2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/log_int.h      2021-03-03 
09:32:09.000000000 +0100
@@ -125,6 +125,7 @@
 void qb_log_dcs_init(void);
 void qb_log_dcs_fini(void);
 struct qb_log_callsite *qb_log_dcs_get(int32_t *newly_created,
+                                      const char *message_id,
                                       const char *function,
                                       const char *filename,
                                       const char *format,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/log_syslog.c 
new/libqb-2.0.3+20210303.404adbc/lib/log_syslog.c
--- old/libqb-2.0.2+20201203.def947e/lib/log_syslog.c   2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/log_syslog.c   2021-03-03 
09:32:09.000000000 +0100
@@ -64,13 +64,24 @@
        }
 #ifdef USE_JOURNAL
        if (t->use_journal) {
-               sd_journal_send("PRIORITY=%d", final_priority,
+               if (cs->message_id) {
+                       sd_journal_send("MESSAGE_ID=%s", cs->message_id,
+                               "PRIORITY=%d", final_priority,
                                "CODE_LINE=%d", cs->lineno,
                                "CODE_FILE=%s", cs->filename,
                                "CODE_FUNC=%s", cs->function,
                                "SYSLOG_IDENTIFIER=%s", t->name,
                                "MESSAGE=%s", output_buffer,
                                NULL);
+               } else {
+                       sd_journal_send("PRIORITY=%d", final_priority,
+                               "CODE_LINE=%d", cs->lineno,
+                               "CODE_FILE=%s", cs->filename,
+                               "CODE_FUNC=%s", cs->function,
+                               "SYSLOG_IDENTIFIER=%s", t->name,
+                               "MESSAGE=%s", output_buffer,
+                               NULL);
+               }
        } else {
 #endif
                syslog(final_priority, "%s", output_buffer);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/loop_timerlist.c 
new/libqb-2.0.3+20210303.404adbc/lib/loop_timerlist.c
--- old/libqb-2.0.2+20201203.def947e/lib/loop_timerlist.c       2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/loop_timerlist.c       2021-03-03 
09:32:09.000000000 +0100
@@ -44,6 +44,7 @@
        struct timerlist timerlist;
        qb_array_t *timers;
        size_t timer_entry_count;
+       pthread_mutex_t lock;
 };
 
 static void
@@ -104,6 +105,7 @@
        timerlist_init(&my_src->timerlist);
        my_src->timers = qb_array_create_2(16, sizeof(struct qb_loop_timer), 
16);
        my_src->timer_entry_count = 0;
+       pthread_mutex_init(&my_src->lock, NULL);
 
        return (struct qb_loop_source *)my_src;
 }
@@ -192,6 +194,9 @@
        }
        my_src = (struct qb_timer_source *)l->timer_source;
 
+       if (pthread_mutex_lock(&my_src->lock)) {
+               return -errno;
+       }
        i = _get_empty_array_position_(my_src);
        assert(qb_array_index(my_src->timers, i, (void **)&t) >= 0);
        t->state = QB_POLL_ENTRY_ACTIVE;
@@ -202,6 +207,9 @@
        t->p = p;
        qb_list_init(&t->item.list);
 
+       /* Unlock here to stop anyone else changing the state while we're 
initializing */
+       pthread_mutex_unlock(&my_src->lock);
+
        /*
         * Make sure just positive integers are used for the integrity(?)
         * checks within 2^32 address space, if we miss 200 times in a row
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/lib/strlcpy.c 
new/libqb-2.0.3+20210303.404adbc/lib/strlcpy.c
--- old/libqb-2.0.2+20201203.def947e/lib/strlcpy.c      2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/lib/strlcpy.c      2021-03-03 
09:32:09.000000000 +0100
@@ -33,8 +33,12 @@
        size_t  srclen = strlen(src);
        size_t  len2cpy = QB_MIN(maxlen-1, srclen);
 
-       if (len2cpy > 0) {
-               strncpy(dest, src, len2cpy+1);
+       /* check maxlen separately as it could have underflowed from 0 above. */
+       if (maxlen) {
+               if (len2cpy > 0) {
+                       strncpy(dest, src, len2cpy+1);
+               }
+               /* Always terminate, even if its empty */
                dest[len2cpy] = '\0';
        }
        return srclen;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/tests/check_log.c 
new/libqb-2.0.3+20210303.404adbc/tests/check_log.c
--- old/libqb-2.0.2+20201203.def947e/tests/check_log.c  2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/tests/check_log.c  2021-03-03 
09:32:09.000000000 +0100
@@ -1021,12 +1021,13 @@
        pid_t log_pid;
        sd_journal *jnl;
        int count = 0;
+       const char *msgid="f77379a8490b408bbe5f6940505a777b";
 
        qb_log_init("check_log", LOG_USER, LOG_DEBUG);
        qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_TRUE);
        rc = qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_USE_JOURNAL, 1);
        ck_assert_int_eq(rc, 0);
-       qb_log(LOG_ERR, "Test message 1 from libqb");
+       qb_log2(msgid, LOG_ERR, "Test message 1 from libqb");
 
        qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_TRUE);
        rc = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_USE_JOURNAL, 1);
@@ -1046,6 +1047,9 @@
            if (log_pid == getpid()) {
                rc = sd_journal_get_data(jnl, "MESSAGE", (const void **)&msg, 
&len);
                ck_assert_int_eq(rc, 0);
+               rc = sd_journal_get_data(jnl, "MESSAGE_ID", (const void 
**)&msg, &len);
+               ck_assert_int_eq(rc, 0);
+               ck_assert_str_eq(msg+11, msgid);
                break;
            }
            if (++count > 20) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/tests/check_loop.c 
new/libqb-2.0.3+20210303.404adbc/tests/check_loop.c
--- old/libqb-2.0.2+20201203.def947e/tests/check_loop.c 2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/tests/check_loop.c 2021-03-03 
09:32:09.000000000 +0100
@@ -439,6 +439,56 @@
 }
 END_TEST
 
+static void *loop_timer_thread(void *arg)
+{
+       int res;
+       qb_loop_t *l = (qb_loop_t *)arg;
+       qb_loop_timer_handle test_tht;
+
+       res = qb_loop_timer_add(l, QB_LOOP_LOW, 5*QB_TIME_NS_IN_MSEC, l, 
one_shot_tmo, &test_tht);
+       ck_assert_int_eq(res, 0);
+
+       res = qb_loop_timer_is_running(l, test_th);
+       ck_assert_int_eq(res, QB_TRUE);
+
+       sleep(5);
+
+       return (void *)0;
+}
+
+/* This test will probably never fail (unless something
+   really bad happens) but is useful for running under
+   helgrind to find threading issues */
+START_TEST(test_loop_timer_threads)
+{
+       int32_t res;
+       pthread_t thr;
+       qb_loop_t *l = qb_loop_create();
+       ck_assert(l != NULL);
+
+       res = pthread_create(&thr, NULL, loop_timer_thread, l);
+
+       res = qb_loop_timer_add(l, QB_LOOP_LOW, 7*QB_TIME_NS_IN_MSEC, l, 
reset_one_shot_tmo, &reset_th);
+       ck_assert_int_eq(res, 0);
+
+       res = qb_loop_timer_add(l, QB_LOOP_HIGH, 20*QB_TIME_NS_IN_MSEC, l, 
check_time_left, &test_th2);
+       ck_assert_int_eq(res, 0);
+
+       res = qb_loop_timer_add(l, QB_LOOP_LOW, 60*QB_TIME_NS_IN_MSEC, l, 
job_stop, &test_th);
+       ck_assert_int_eq(res, 0);
+
+       qb_loop_run(l);
+
+       ck_assert_int_eq(reset_timer_step, 2);
+
+       pthread_join(thr, NULL);
+       qb_loop_destroy(l);
+}
+END_TEST
+
+
+
+
 struct qb_stop_watch {
        uint64_t start;
        uint64_t end;
@@ -742,6 +792,7 @@
        add_tcase(s, tc, test_loop_timer_basic, 30);
        add_tcase(s, tc, test_loop_timer_precision, 30);
        add_tcase(s, tc, test_loop_timer_expire_leak, 30);
+       add_tcase(s, tc, test_loop_timer_threads, 30);
 
        return s;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libqb-2.0.2+20201203.def947e/tests/resources.test 
new/libqb-2.0.3+20210303.404adbc/tests/resources.test
--- old/libqb-2.0.2+20201203.def947e/tests/resources.test       2020-12-03 
14:05:43.000000000 +0100
+++ new/libqb-2.0.3+20210303.404adbc/tests/resources.test       2021-03-03 
09:32:09.000000000 +0100
@@ -1,17 +1,31 @@
 #!/bin/sh
 RETURN=0
+SOCKS_PER_PROCESS=3
 
 IPC_NAME=`cat ipc-test-name 2>/dev/null`
 for d in /dev/shm /var/run $SOCKETDIR; do
-       leftovers=$(find $d -name qb-test*${IPC_NAME}* -size +0c 2>/dev/null | 
wc -l)
+
+       # Tidy up the deadlock checker sockets first
+       dlocks=$(find $d -name qb-*-test_*dlock*${IPC_NAME}* -size +0c 
2>/dev/null)
+       if [ `echo $dlocks|wc -w` -eq $(($SOCKS_PER_PROCESS * 6)) ]; then
+               rm $dlocks
+       elif [ -n "${dlocks}" ]; then
+               echo
+               echo "Error: dlock shared memory segments not closed/unlinked"
+               echo
+               RETURN=1
+       fi
+
+       # Now look for other leftovers
+       leftovers=$(find $d -name qb-*-test_*${IPC_NAME}* -size +0c 2>/dev/null 
| wc -l)
        if [ "${leftovers}" -gt 0 ]; then
                echo
                echo "Error: shared memory segments not closed/unlinked"
                echo
                RETURN=1
        fi
-       leftovers="$(find $d -name qb-test*${IPC_NAME}* -size 0c 2>/dev/null)"
-       if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq 6 ]; then
+       leftovers="$(find $d -name qb-*-test_*${IPC_NAME}* -size 0c 
2>/dev/null)"
+       if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq 
$(($SOCKS_PER_PROCESS * 2)) ]; then
                echo
                echo "There were some empty leftovers (expected), removing them"
                echo "${leftovers}" | tee /dev/stderr | xargs rm

Reply via email to