The branch, master has been updated
       via  d191436 lib: tdb: Use sigaction when testing for robust mutexes.
      from  e67130c Explicitly include util/debug.h from server stubs generated 
by pidl.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d1914367289b58f26544ee6e116490d662d9c41c
Author: Jeremy Allison <[email protected]>
Date:   Fri Mar 20 10:59:08 2015 -0700

    lib: tdb: Use sigaction when testing for robust mutexes.
    
    Fixes bug #11175 - Lots of winbindd zombie processes on Solaris platform.
    
    https://bugzilla.samba.org/show_bug.cgi?id=11175
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Tue Mar 24 14:43:22 CET 2015 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/mutex.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/mutex.c b/lib/tdb/common/mutex.c
index 12f89d3..d45cce8 100644
--- a/lib/tdb/common/mutex.c
+++ b/lib/tdb/common/mutex.c
@@ -713,6 +713,27 @@ cleanup_ma:
 static void (*tdb_robust_mutext_old_handler)(int) = SIG_ERR;
 static pid_t tdb_robust_mutex_pid = -1;
 
+static void (*tdb_robust_mutex_setup_sigchild(void (*handler)(int)))(int)
+{
+#ifdef HAVE_SIGACTION
+       struct sigaction act;
+       struct sigaction oldact;
+
+       memset(&act, '\0', sizeof(act));
+
+       act.sa_handler = handler;
+#ifdef SA_RESTART
+       act.sa_flags = SA_RESTART;
+#endif
+       sigemptyset(&act.sa_mask);
+       sigaddset(&act.sa_mask, SIGCHLD);
+       sigaction(SIGCHLD, &act, &oldact);
+       return oldact.sa_handler;
+#else /* !HAVE_SIGACTION */
+       return NULL;
+#endif
+}
+
 static void tdb_robust_mutex_handler(int sig)
 {
        if (tdb_robust_mutex_pid != -1) {
@@ -803,8 +824,11 @@ _PUBLIC_ bool tdb_runtime_check_for_robust_mutexes(void)
                goto cleanup_ma;
        }
 
-       tdb_robust_mutext_old_handler = signal(SIGCHLD,
-                                              tdb_robust_mutex_handler);
+       tdb_robust_mutext_old_handler = tdb_robust_mutex_setup_sigchild(
+                                               tdb_robust_mutex_handler);
+       if (tdb_robust_mutext_old_handler == NULL) {
+               goto cleanup_ma;
+       }
 
        tdb_robust_mutex_pid = fork();
        if (tdb_robust_mutex_pid == 0) {
@@ -869,7 +893,7 @@ _PUBLIC_ bool tdb_runtime_check_for_robust_mutexes(void)
                        goto cleanup_child;
                }
        }
-       signal(SIGCHLD, tdb_robust_mutext_old_handler);
+       tdb_robust_mutex_setup_sigchild(tdb_robust_mutext_old_handler);
 
        ret = pthread_mutex_trylock(m);
        if (ret != EOWNERDEAD) {
@@ -915,7 +939,7 @@ cleanup_child:
                }
        }
 cleanup_sig_child:
-       signal(SIGCHLD, tdb_robust_mutext_old_handler);
+       tdb_robust_mutex_setup_sigchild(tdb_robust_mutext_old_handler);
 cleanup_m:
        pthread_mutex_destroy(m);
 cleanup_ma:


-- 
Samba Shared Repository

Reply via email to