pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc Solarish pthreads expect mutex datastructures to be pr...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/41fbae49a098
branches:  trunk
changeset: 400835:41fbae49a098
user:      hauke <hauke%pkgsrc.org@localhost>
date:      Thu Sep 05 12:39:56 2019 +0000

description:
Solarish pthreads expect mutex datastructures to be properly zeroed
out, unlike the Linux implementation, which upstream mainly
targets. This leads to "tdb_open_ex: tdb_mutex_init failed for
/var/samba/lock/gencache.tdb: Device busy" errors, described in
<https://illumos.topicbox.com/groups/developer/T28dcabf2f69cac04>.

Illumos kernel code attempted to mitigate the problem as of
<https://www.illumos.org/issues/9959>, but the changes have yet to
show up in releases.

The patches originate from
<https://github.com/oposs/pkg.oetiker.ch-build/blob/master/build/samba4/patches/pthread_mutex_init>,
modified appropriately.

Tested on omniosce r151030.

diffstat:

 databases/tdb/Makefile                                                  |   3 +-
 databases/tdb/distinfo                                                  |   3 +-
 databases/tdb/patches/patch-common_mutex.c                              |  63 ++++++++++
 net/samba4/Makefile                                                     |   3 +-
 net/samba4/distinfo                                                     |  15 ++-
 net/samba4/patches/patch-buildtools_wafsamba_wscript                    |   4 +-
 net/samba4/patches/patch-lib_pthreadpool_pthreadpool.c                  |  23 +++
 net/samba4/patches/patch-lib_tdb_common_mutex.c                         |  63 ++++++++++
 net/samba4/patches/patch-lib_tevent_tevent.c                            |  15 ++
 net/samba4/patches/patch-lib_tevent_tevent__threads.c                   |  23 +++
 net/samba4/patches/patch-lib_util_smb__threads.h                        |  15 ++
 net/samba4/patches/patch-lib_util_tfork.c                               |  15 ++
 net/samba4/patches/patch-nsswitch_stress-nss-libwbclient.c              |  15 ++
 net/samba4/patches/patch-source3_libsmb_pylibsmb.c                      |  15 ++
 net/samba4/patches/patch-source3_smbd_process.c                         |  23 +++
 net/samba4/patches/patch-source4_heimdal_include_heim__threads.h        |  16 ++
 net/samba4/patches/patch-third__party_socket__wrapper_socket__wrapper.c |  23 +++
 17 files changed, 330 insertions(+), 7 deletions(-)

diffs (truncated from 451 to 300 lines):

diff -r e33fb69d89b8 -r 41fbae49a098 databases/tdb/Makefile
--- a/databases/tdb/Makefile    Thu Sep 05 10:43:50 2019 +0000
+++ b/databases/tdb/Makefile    Thu Sep 05 12:39:56 2019 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.40 2019/08/23 10:49:14 adam Exp $
+# $NetBSD: Makefile,v 1.41 2019/09/05 12:39:56 hauke Exp $
 
 DISTNAME=      tdb-1.4.2
+PKGREVISION=   1
 CATEGORIES=    databases
 MASTER_SITES=  http://www.samba.org/ftp/tdb/
 
diff -r e33fb69d89b8 -r 41fbae49a098 databases/tdb/distinfo
--- a/databases/tdb/distinfo    Thu Sep 05 10:43:50 2019 +0000
+++ b/databases/tdb/distinfo    Thu Sep 05 12:39:56 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.21 2019/08/23 10:49:14 adam Exp $
+$NetBSD: distinfo,v 1.22 2019/09/05 12:39:56 hauke Exp $
 
 SHA1 (tdb-1.4.2.tar.gz) = 9a6e51cde16a2400b76448c4e7de2f87656477a2
 RMD160 (tdb-1.4.2.tar.gz) = 8dac17b4b272a4df61b385b4ba3c297e1bcbb6c7
@@ -7,3 +7,4 @@
 SHA1 (patch-buildtools_wafsamba_samba__conftests.py) = 50ff76f5b085f770751ca8bb93c8544cfdcd40d9
 SHA1 (patch-buildtools_wafsamba_samba__install.py) = d801340617da325e3bb70a90350e45cc8e383c2d
 SHA1 (patch-buildtools_wafsamba_samba__utils.py) = 0a587421870c1974175fadbb02dde215f35938f2
+SHA1 (patch-common_mutex.c) = 4dc326c8a5e7230be8ab3ff9b6cc5548df90430f
diff -r e33fb69d89b8 -r 41fbae49a098 databases/tdb/patches/patch-common_mutex.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/tdb/patches/patch-common_mutex.c        Thu Sep 05 12:39:56 2019 +0000
@@ -0,0 +1,63 @@
+$NetBSD: patch-common_mutex.c,v 1.1 2019/09/05 12:39:56 hauke Exp $
+
+On SunOS (OpenSolaris), pthread_mutex_init() expects a zeroed-out
+mutex data structure
+
+--- common/mutex.c.orig        2017-04-28 08:57:26.000000000 +0000
++++ common/mutex.c
+@@ -567,6 +567,7 @@ int tdb_mutex_init(struct tdb_context *t
+       }
+       m = tdb->mutexes;
+ 
++        memset(&ma, 0, sizeof(pthread_mutexattr_t));
+       ret = pthread_mutexattr_init(&ma);
+       if (ret != 0) {
+               goto fail_munmap;
+@@ -587,6 +588,7 @@ int tdb_mutex_init(struct tdb_context *t
+       for (i=0; i<tdb->hash_size+1; i++) {
+               pthread_mutex_t *chain = &m->hashchains[i];
+ 
++                memset(chain, 0, sizeof(pthread_mutex_t));
+               ret = pthread_mutex_init(chain, &ma);
+               if (ret != 0) {
+                       goto fail;
+@@ -595,6 +597,7 @@ int tdb_mutex_init(struct tdb_context *t
+ 
+       m->allrecord_lock = F_UNLCK;
+ 
++        memset(&m->allrecord_mutex, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&m->allrecord_mutex, &ma);
+       if (ret != 0) {
+               goto fail;
+@@ -672,6 +675,7 @@ static bool tdb_mutex_locking_supported(
+ 
+       initialized = true;
+ 
++      memset(&ma, 0, sizeof(pthread_mutexattr_t));
+       ret = pthread_mutexattr_init(&ma);
+       if (ret != 0) {
+               return false;
+@@ -688,6 +692,7 @@ static bool tdb_mutex_locking_supported(
+       if (ret != 0) {
+               goto cleanup_ma;
+       }
++        memset(&m, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&m, &ma);
+       if (ret != 0) {
+               goto cleanup_ma;
+@@ -868,6 +873,7 @@ _PUBLIC_ bool tdb_runtime_check_for_robu
+               goto cleanup;
+       }
+ 
++        memset(&ma, 0, sizeof(pthread_mutexattr_t));
+       ret = pthread_mutexattr_init(&ma);
+       if (ret != 0) {
+               goto cleanup;
+@@ -885,6 +891,7 @@ _PUBLIC_ bool tdb_runtime_check_for_robu
+       if (ret != 0) {
+               goto cleanup;
+       }
++        memset(ptr, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(ptr, &ma);
+       if (ret != 0) {
+               goto cleanup;
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/Makefile
--- a/net/samba4/Makefile       Thu Sep 05 10:43:50 2019 +0000
+++ b/net/samba4/Makefile       Thu Sep 05 12:39:56 2019 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.79 2019/09/04 08:15:32 taca Exp $
+# $NetBSD: Makefile,v 1.80 2019/09/05 12:39:56 hauke Exp $
 
 DISTNAME=      samba-4.10.8
+PKGREVISION=   1
 CATEGORIES=    net
 MASTER_SITES=  https://download.samba.org/pub/samba/stable/
 MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/distinfo
--- a/net/samba4/distinfo       Thu Sep 05 10:43:50 2019 +0000
+++ b/net/samba4/distinfo       Thu Sep 05 12:39:56 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.35 2019/09/03 19:11:58 adam Exp $
+$NetBSD: distinfo,v 1.36 2019/09/05 12:39:56 hauke Exp $
 
 SHA1 (samba-4.10.8.tar.gz) = e0fafe34e7205c4f9ab54f96ab2ee72d1b9cfaca
 RMD160 (samba-4.10.8.tar.gz) = ee2f253b30e1ecdd796c8c92f3d7c5fae7ec0694
@@ -8,16 +8,27 @@
 SHA1 (patch-buildtools_wafsamba_samba__install.py) = d801340617da325e3bb70a90350e45cc8e383c2d
 SHA1 (patch-buildtools_wafsamba_samba__pidl.py) = a7cc41a55ce032c3fe1e0b660f88fa7871710e0e
 SHA1 (patch-buildtools_wafsamba_samba__utils.py) = 0a587421870c1974175fadbb02dde215f35938f2
-SHA1 (patch-buildtools_wafsamba_wscript) = 5604936a825675647157331df2333f4237c611f5
+SHA1 (patch-buildtools_wafsamba_wscript) = 117fb13f5266dc90568b18ffa8faa34a45bc94c5
 SHA1 (patch-docs-xml_wscript__build) = 5aa5cbf61882604b7ec9d19f0cd1537a23705ad0
 SHA1 (patch-dynconfig_wscript) = 1858e5fcca913f21aa3e7868d9760b9c40c9f5c4
 SHA1 (patch-lib_param_loadparm.h) = 0216b69d33d1e17260a446e11bee764116c52b18
+SHA1 (patch-lib_pthreadpool_pthreadpool.c) = c29490473063d6bdbe5c50780a21bf2869ae959f
 SHA1 (patch-lib_replace_wscript) = 2a754e7310850b376d5881b82a8467041284fce9
+SHA1 (patch-lib_tdb_common_mutex.c) = 12dbcf870e6ba17ef7f92a8ce7f0b7462f820232
+SHA1 (patch-lib_tevent_tevent.c) = 4a20506e2bfbab85bad664299b884575326e73fd
+SHA1 (patch-lib_tevent_tevent__threads.c) = 14867888dd0b7c4613914752ab368c39bfdbb943
 SHA1 (patch-lib_tevent_wscript) = fbbe2024096b57d651d90064f53489a974db9d7a
+SHA1 (patch-lib_util_smb__threads.h) = 93bbc4276ad927ad6faf305af093064f47c09254
+SHA1 (patch-lib_util_tfork.c) = cd70dcff5f2ce94ffe642e0f029f03ee07dff27d
 SHA1 (patch-libcli_dns_wscript__build) = 40e6f864e2fb1b6abb198f1a51bb2c95bc8c6fb2
+SHA1 (patch-nsswitch_stress-nss-libwbclient.c) = bf327282a59aefeeb2d6bf9eccf9b3a832033066
 SHA1 (patch-nsswitch_winbind__nss__netbsd.c) = 71d8acd0aa4c297d75555fba650461c778495caa
 SHA1 (patch-nsswitch_wscript__build) = e8a6251e031ffa13d6347fade8891f7afd65d3eb
+SHA1 (patch-source3_libsmb_pylibsmb.c) = 50c3aaecf345449e02642e387eeac3dd7043e77a
+SHA1 (patch-source3_smbd_process.c) = 532d2426b9bd2a215d133bc489741558aa07f849
 SHA1 (patch-source4_dsdb_samdb_ldb__modules_wscript__build__server) = c322cf56995192039fa22548d6d6e50641c4c796
 SHA1 (patch-source4_heimdal__build_roken.h) = ee535f8e7cc46a3487d95bc859438c476a88fe60
 SHA1 (patch-source4_heimdal__build_wscript__configure) = 82f9da47f7dc4c3fc29f93b1e9829a1a3b54c095
+SHA1 (patch-source4_heimdal_include_heim__threads.h) = c93e0c80790ea2045333822c80e66d371bf2249c
 SHA1 (patch-source4_scripting_wsript_build) = bd4feddcaadf1c3d2d25eb7914e7b5843e4e9511
+SHA1 (patch-third__party_socket__wrapper_socket__wrapper.c) = 0cc01c932f21e9f6219fb9d204e6fdf3682938f8
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/patches/patch-buildtools_wafsamba_wscript
--- a/net/samba4/patches/patch-buildtools_wafsamba_wscript      Thu Sep 05 10:43:50 2019 +0000
+++ b/net/samba4/patches/patch-buildtools_wafsamba_wscript      Thu Sep 05 12:39:56 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: patch-buildtools_wafsamba_wscript,v 1.1 2015/05/26 15:11:26 jperkin Exp $
+$NetBSD: patch-buildtools_wafsamba_wscript,v 1.2 2019/09/05 12:39:56 hauke Exp $
 
 Define _POSIX_PTHREAD_SEMANTICS on SunOS to pick up re-entrant functions.
 
@@ -8,7 +8,7 @@
      conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
      conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
  
-+    # Use POSIX getpwnam_r and friends.
++    # Use POSIX getpwnam_r and friends.
 +    if conf.env['SYSTEM_UNAME_SYSNAME'] == 'SunOS':
 +        conf.DEFINE('_POSIX_PTHREAD_SEMANTICS', 1, add_to_cflags=True)
 +
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/patches/patch-lib_pthreadpool_pthreadpool.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/samba4/patches/patch-lib_pthreadpool_pthreadpool.c    Thu Sep 05 12:39:56 2019 +0000
@@ -0,0 +1,23 @@
+$NetBSD: patch-lib_pthreadpool_pthreadpool.c,v 1.1 2019/09/05 12:39:56 hauke Exp $
+
+On SunOS (OpenSolaris), pthread_mutex_init() expects a zeroed-out
+mutex data structure
+    
+--- lib/pthreadpool/pthreadpool.c.orig 2019-01-15 10:07:00.000000000 +0000
++++ lib/pthreadpool/pthreadpool.c
+@@ -153,6 +153,7 @@ int pthreadpool_init(unsigned max_thread
+ 
+       pool->head = pool->num_jobs = 0;
+ 
++      memset(&pool->mutex, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&pool->mutex, NULL);
+       if (ret != 0) {
+               free(pool->jobs);
+@@ -168,6 +169,7 @@ int pthreadpool_init(unsigned max_thread
+               return ret;
+       }
+ 
++      memset(&pool->fork_mutex, 0, sizeof(pthread_mutex_t));  
+       ret = pthread_mutex_init(&pool->fork_mutex, NULL);
+       if (ret != 0) {
+               pthread_cond_destroy(&pool->condvar);
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/patches/patch-lib_tdb_common_mutex.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/samba4/patches/patch-lib_tdb_common_mutex.c   Thu Sep 05 12:39:56 2019 +0000
@@ -0,0 +1,63 @@
+$NetBSD: patch-lib_tdb_common_mutex.c,v 1.1 2019/09/05 12:39:56 hauke Exp $
+
+On SunOS (OpenSolaris), pthread_mutex_init() expects a zeroed-out
+mutex data structure
+    
+--- lib/tdb/common/mutex.c.orig        2019-01-15 10:07:00.000000000 +0000
++++ lib/tdb/common/mutex.c
+@@ -567,6 +567,7 @@ int tdb_mutex_init(struct tdb_context *t
+       }
+       m = tdb->mutexes;
+ 
++      memset(&ma, 0, sizeof(pthread_mutexattr_t));
+       ret = pthread_mutexattr_init(&ma);
+       if (ret != 0) {
+               goto fail_munmap;
+@@ -587,6 +588,7 @@ int tdb_mutex_init(struct tdb_context *t
+       for (i=0; i<tdb->hash_size+1; i++) {
+               pthread_mutex_t *chain = &m->hashchains[i];
+ 
++              memset(chain, 0, sizeof(pthread_mutex_t));
+               ret = pthread_mutex_init(chain, &ma);
+               if (ret != 0) {
+                       goto fail;
+@@ -595,6 +597,7 @@ int tdb_mutex_init(struct tdb_context *t
+ 
+       m->allrecord_lock = F_UNLCK;
+ 
++      memset(&m->allrecord_mutex, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&m->allrecord_mutex, &ma);
+       if (ret != 0) {
+               goto fail;
+@@ -672,6 +675,7 @@ static bool tdb_mutex_locking_supported(
+ 
+       initialized = true;
+ 
++      memset(&ma, 0, sizeof(pthread_mutexattr_t));
+       ret = pthread_mutexattr_init(&ma);
+       if (ret != 0) {
+               return false;
+@@ -688,6 +692,7 @@ static bool tdb_mutex_locking_supported(
+       if (ret != 0) {
+               goto cleanup_ma;
+       }
++      memset(&m, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&m, &ma);
+       if (ret != 0) {
+               goto cleanup_ma;
+@@ -868,6 +873,7 @@ _PUBLIC_ bool tdb_runtime_check_for_robu
+               goto cleanup;
+       }
+ 
++      memset(&ma, 0, sizeof(pthread_mutexattr_t));
+       ret = pthread_mutexattr_init(&ma);
+       if (ret != 0) {
+               goto cleanup;
+@@ -885,6 +891,7 @@ _PUBLIC_ bool tdb_runtime_check_for_robu
+       if (ret != 0) {
+               goto cleanup;
+       }
++      memset(ptr, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(ptr, &ma);
+       if (ret != 0) {
+               goto cleanup;
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/patches/patch-lib_tevent_tevent.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/samba4/patches/patch-lib_tevent_tevent.c      Thu Sep 05 12:39:56 2019 +0000
@@ -0,0 +1,15 @@
+$NetBSD: patch-lib_tevent_tevent.c,v 1.1 2019/09/05 12:39:56 hauke Exp $
+
+On SunOS (OpenSolaris), pthread_mutex_init() expects a zeroed-out
+mutex data structure
+    
+--- lib/tevent/tevent.c.orig   2019-01-15 10:07:00.000000000 +0000
++++ lib/tevent/tevent.c
+@@ -423,6 +423,7 @@ static int tevent_common_context_constru
+               return ret;
+       }
+ 
++      memset(&ev->scheduled_mutex, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&ev->scheduled_mutex, NULL);
+       if (ret != 0) {
+               return ret;
diff -r e33fb69d89b8 -r 41fbae49a098 net/samba4/patches/patch-lib_tevent_tevent__threads.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/samba4/patches/patch-lib_tevent_tevent__threads.c     Thu Sep 05 12:39:56 2019 +0000
@@ -0,0 +1,23 @@
+$NetBSD: patch-lib_tevent_tevent__threads.c,v 1.1 2019/09/05 12:39:56 hauke Exp $
+
+On SunOS (OpenSolaris), pthread_mutex_init() expects a zeroed-out
+mutex data structure
+    
+--- lib/tevent/tevent_threads.c.orig   2019-01-15 10:07:00.000000000 +0000
++++ lib/tevent/tevent_threads.c
+@@ -234,6 +234,7 @@ struct tevent_thread_proxy *tevent_threa
+               return NULL;
+       }
+ 
++      memset(&tp->mutex, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&tp->mutex, NULL);
+       if (ret != 0) {
+               goto fail;
+@@ -439,6 +440,7 @@ struct tevent_threaded_context *tevent_t
+       }
+       tctx->event_ctx = ev;
+ 
++      memset(&tctx->event_ctx_mutex, 0, sizeof(pthread_mutex_t));
+       ret = pthread_mutex_init(&tctx->event_ctx_mutex, NULL);
+       if (ret != 0) {



Home | Main Index | Thread Index | Old Index