Hello community,

here is the log from the commit of package czmq for openSUSE:Factory checked in 
at 2016-10-18 10:42:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/czmq (Old)
 and      /work/SRC/openSUSE:Factory/.czmq.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "czmq"

Changes:
--------
--- /work/SRC/openSUSE:Factory/czmq/czmq.changes        2015-07-12 
22:52:46.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.czmq.new/czmq.changes   2016-10-18 
10:42:43.000000000 +0200
@@ -1,0 +2,5 @@
+Wed Oct 12 22:21:36 UTC 2016 - mvysko...@opensuse.org
+
+- add 0001-readdir_r-deprecated.patch to fix a build in Tumbleweed
+
+-------------------------------------------------------------------

New:
----
  0001-readdir_r-deprecated.patch

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

Other differences:
------------------
++++++ czmq.spec ++++++
--- /var/tmp/diff_new_pack.F7uRpw/_old  2016-10-18 10:42:44.000000000 +0200
+++ /var/tmp/diff_new_pack.F7uRpw/_new  2016-10-18 10:42:44.000000000 +0200
@@ -1,7 +1,7 @@
 #
-# spec file for package 
+# spec file for package czmq
 #
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,21 +15,24 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
+
 Name:           czmq
 Version:        3.0.2
 Release:        0
-License:        MPL-2.0
 Summary:        High-level C binding for ØMQ
-Url:            https://github.com/zeromq/czmq
+License:        MPL-2.0
 Group:          Development/Libraries/C and C++
+Url:            https://github.com/zeromq/czmq
 Source0:        http://download.zeromq.org/%{name}-%{version}.tar.gz
+#PATCH-FIX-UPSTREAM
+Patch0:         0001-readdir_r-deprecated.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-BuildRequires:  pkgconfig(libzmq) > 4.1
-BuildRequires:  pkgconfig(libsodium)
-BuildRequires:  pkg-config
-BuildRequires:  libtool
 BuildRequires:  autoconf
 BuildRequires:  automake
+BuildRequires:  libtool
+BuildRequires:  pkg-config
+BuildRequires:  pkgconfig(libsodium)
+BuildRequires:  pkgconfig(libzmq) > 4.1
 # documentation
 BuildRequires:  asciidoc
 BuildRequires:  xmlto
@@ -61,6 +64,7 @@
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %configure --disable-static

++++++ 0001-readdir_r-deprecated.patch ++++++
commit 2594d406d8ec6f54e54d7570d7febba10a6906b2
Author: Luca Boccassi <luca.bocca...@gmail.com>
Date:   Thu Sep 1 18:02:48 2016 +0100

    Problem: readdir_r deprecated in glibc 2.24
    
    Solution: use readdir and protect the calls to it with a global mutex.
    This is necessary because readdir has not yet been made thread safe.
    It might happen in the next version of POSIX, but until then we must
    ensure 2 threads never call readdir on the same directory, so a mutex
    is necessary.

diff --git a/src/zdir.c b/src/zdir.c
index cc6e9b0..4c72158 100644
--- a/src/zdir.c
+++ b/src/zdir.c
@@ -91,6 +91,9 @@ s_posix_populate_entry (zdir_t *self, struct dirent *entry)
 }
 #endif
 
+#ifndef WIN32
+static pthread_mutex_t s_readdir_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
 
 //  --------------------------------------------------------------------------
 //  Create a new directory item that loads in the full tree of the specified
@@ -175,22 +178,22 @@ zdir_new (const char *path, const char *parent)
 
     DIR *handle = opendir (self->path);
     if (handle) {
-        //  Calculate system-specific size of dirent block
-        int dirent_size = offsetof (struct dirent, d_name)
-                          + pathconf (self->path, _PC_NAME_MAX) + 1;
-        struct dirent *entry = (struct dirent *) zmalloc (dirent_size);
-        if (!entry) {
-            zdir_destroy (&self);
-            return NULL;
-        }
-        struct dirent *result;
-
-        int rc = readdir_r (handle, entry, &result);
-        while (rc == 0 && result != NULL) {
+        // readdir_r is deprecated in glibc 2.24, but readdir is still not
+        // guaranteed to be thread safe if the same directory is accessed
+        // by different threads at the same time. Unfortunately given it was
+        // not a constraint before we cannot change it now as it would be an
+        // API breakage. Use a global lock when scanning the directory to
+        // work around it.
+        pthread_mutex_lock (&s_readdir_mutex);
+        struct dirent *entry = readdir (handle);
+        pthread_mutex_unlock (&s_readdir_mutex);
+        while (entry != NULL) {
+            // Beware of recursion. Lock only around readdir calls.
             s_posix_populate_entry (self, entry);
-            rc = readdir_r (handle, entry, &result);
+            pthread_mutex_lock (&s_readdir_mutex);
+            entry = readdir (handle);
+            pthread_mutex_unlock (&s_readdir_mutex);
         }
-        free (entry);
         closedir (handle);
     }
 #endif

Reply via email to