The branch, v3-6-test has been updated
       via  64a29fd tevent: Fix bug 9550 - sigprocmask does not work on FreeBSD 
to stop further signals in a signal handler
       via  9a21bc3 lib/replace: Include sys/ucontext.h if available.
       via  d78f760 lib/replace: Add ucontext configure autoconf checks.
       via  8de4edd lib/replace: Add missing check for sys/wait.h
      from  c89f3dd Fix bug 9548: Correctly detect O_DIRECT

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 64a29fdf0e3ec9138e946bab03ad28a965f3ebd0
Author: Jeremy Allison <[email protected]>
Date:   Mon Jan 14 15:22:11 2013 -0800

    tevent: Fix bug 9550 - sigprocmask does not work on FreeBSD to stop further 
signals in a signal handler
    
    Mask off signals the correct way from the signal handler.
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>
    
    Autobuild-User(master): Stefan Metzmacher <[email protected]>
    Autobuild-Date(master): Tue Jan 15 12:13:43 CET 2013 on sn-devel-104

commit 9a21bc35c565210767e71f4bc03a558fe61bdbc8
Author: Jeremy Allison <[email protected]>
Date:   Mon Jan 14 15:21:52 2013 -0800

    lib/replace: Include sys/ucontext.h if available.
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

commit d78f760280473c35b33d4f17d31528dd6269405a
Author: Jeremy Allison <[email protected]>
Date:   Tue Jan 15 10:16:27 2013 -0800

    lib/replace: Add ucontext configure autoconf checks.
    
    Signed-off-by: Jeremy Allison <[email protected]>

commit 8de4edd42cf16bd761a6acc2c8b5656d088969a7
Author: Jeremy Allison <[email protected]>
Date:   Mon Jan 14 15:06:12 2013 -0800

    lib/replace: Add missing check for sys/wait.h
    
    Signed-off-by: Jeremy Allison <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>

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

Summary of changes:
 lib/replace/libreplace.m4  |   15 ++++++++++++++-
 lib/replace/system/wait.h  |    4 ++++
 lib/tevent/tevent_signal.c |   29 +++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index 87e8fdb..67f8e3f 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -66,7 +66,7 @@ AC_FUNC_MEMCMP
 AC_CHECK_FUNCS([pipe strftime srandom random srand rand usleep setbuffer lstat 
getpgrp utime utimes])
 
 AC_CHECK_HEADERS(stdbool.h stdint.h sys/select.h)
-AC_CHECK_HEADERS(setjmp.h utime.h)
+AC_CHECK_HEADERS(setjmp.h utime.h sys/wait.h)
 
 LIBREPLACE_PROVIDE_HEADER([stdint.h])
 LIBREPLACE_PROVIDE_HEADER([stdbool.h])
@@ -105,6 +105,7 @@ AC_CHECK_HEADERS(stdarg.h vararg.h)
 AC_CHECK_HEADERS(sys/mount.h mntent.h)
 AC_CHECK_HEADERS(stropts.h)
 AC_CHECK_HEADERS(unix.h)
+AC_CHECK_HEADERS(sys/ucontext.h)
 
 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror 
strerror_r)
 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
@@ -325,6 +326,18 @@ if test x"$libreplace_cv_struct_timespec" = x"yes"; then
    AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
 fi
 
+AC_CACHE_CHECK([for ucontext_t type],libreplace_cv_ucontext_t, [
+    AC_TRY_COMPILE([
+#include <signal.h>
+#if HAVE_SYS_UCONTEXT_H
+#include <sys/ucontext.h>
+# endif
+],[ucontext_t uc; sigaddset(&uc.uc_sigmask, SIGUSR1);],
+    libreplace_cv_ucontext_t=yes,libreplace_cv_ucontext_t=no)])
+if test x"$libreplace_cv_ucontext_t" = x"yes"; then
+    AC_DEFINE(HAVE_UCONTEXT_T,1,[Whether we have ucontext_t])
+fi
+
 AC_CHECK_FUNCS([printf memset memcpy],,[AC_MSG_ERROR([Required function not 
found])])
 
 echo "LIBREPLACE_BROKEN_CHECKS: END"
diff --git a/lib/replace/system/wait.h b/lib/replace/system/wait.h
index f0c3bdc..146c61a 100644
--- a/lib/replace/system/wait.h
+++ b/lib/replace/system/wait.h
@@ -40,6 +40,10 @@
 #include <setjmp.h>
 #endif
 
+#ifdef HAVE_SYS_UCONTEXT_H
+#include <sys/ucontext.h>
+#endif
+
 #if !defined(HAVE_SIG_ATOMIC_T_TYPE)
 typedef int sig_atomic_t;
 #endif
diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index b790859..cc7fb0a 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -122,10 +122,39 @@ static void tevent_common_signal_handler_info(int signum, 
siginfo_t *info,
        if (count+1 == TEVENT_SA_INFO_QUEUE_COUNT) {
                /* we've filled the info array - block this signal until
                   these ones are delivered */
+#ifdef HAVE_UCONTEXT_T
+               /*
+                * This is the only way for this to work.
+                * By default signum is blocked inside this
+                * signal handler using a temporary mask,
+                * but what we really need to do now is
+                * block it in the callers mask, so it
+                * stays blocked when the temporary signal
+                * handler mask is replaced when we return
+                * from here. The callers mask can be found
+                * in the ucontext_t passed in as the
+                * void *uctx argument.
+                */
+               ucontext_t *ucp = (ucontext_t *)uctx;
+               sigaddset(&ucp->uc_sigmask, signum);
+#else
+               /*
+                * WARNING !!! WARNING !!!!
+                *
+                * This code doesn't work.
+                * By default signum is blocked inside this
+                * signal handler, but calling sigprocmask
+                * modifies the temporary signal mask being
+                * used *inside* this handler, which will be
+                * replaced by the callers signal mask once
+                * we return from here. See Samba
+                * bug #9550 for details.
+                */
                sigset_t set;
                sigemptyset(&set);
                sigaddset(&set, signum);
                sigprocmask(SIG_BLOCK, &set, NULL);
+#endif
                TEVENT_SIG_INCREMENT(sig_state->sig_blocked[signum]);
        }
 }


-- 
Samba Shared Repository

Reply via email to