The branch, v3-4-test has been updated
       via  e41d9e7... s3: signals are processed twice in child.
      from  d502902... Fix bug 7310 - DOS attribute inconsistency with MS Office

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


- Log -----------------------------------------------------------------
commit e41d9e75084170fa41a9e313fa79bf351f879840
Author: Bo Yang <[email protected]>
Date:   Tue Feb 9 17:02:20 2010 +0800

    s3: signals are processed twice in child.
    
    Signed-off-by: Bo Yang <[email protected]>
    (cherry picked from commit 8c8bb51de1ac2baa46ac0736fae12c034288e5d4)
    
    Fix bug #7206 (duplicate signal handler, signals are processed twice in 
child
    process).

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

Summary of changes:
 lib/tevent/tevent.c          |    7 +++++++
 lib/tevent/tevent_internal.h |    1 +
 lib/tevent/tevent_signal.c   |   33 ++++++++++++++++++++++++++++-----
 3 files changed, 36 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index 76a6ac1..ae5fdbd 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -176,6 +176,13 @@ int tevent_common_context_destructor(struct tevent_context 
*ev)
                sn = se->next;
                se->event_ctx = NULL;
                DLIST_REMOVE(ev->signal_events, se);
+               /*
+                * This is important, Otherwise signals
+                * are handled twice in child. eg, SIGHUP.
+                * one added in parent, and another one in
+                * the child. -- BoYang
+                */
+               tevent_cleanup_pending_signal_handlers(se);
        }
 
        return 0;
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index aa7c34a..0c15e35 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -299,6 +299,7 @@ struct tevent_signal *tevent_common_add_signal(struct 
tevent_context *ev,
                                               const char *handler_name,
                                               const char *location);
 int tevent_common_check_signal(struct tevent_context *ev);
+void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se);
 
 bool tevent_standard_init(void);
 bool tevent_select_init(void);
diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index ab170a6..f3e22db 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -133,7 +133,9 @@ static void tevent_common_signal_handler_info(int signum, 
siginfo_t *info,
 
 static int tevent_common_signal_list_destructor(struct 
tevent_common_signal_list *sl)
 {
-       DLIST_REMOVE(sig_state->sig_handlers[sl->se->signum], sl);
+       if (sig_state->sig_handlers[sl->se->signum]) {
+               DLIST_REMOVE(sig_state->sig_handlers[sl->se->signum], sl);
+       }
        return 0;
 }
 
@@ -154,12 +156,16 @@ static int tevent_signal_destructor(struct tevent_signal 
*se)
 
        if (sig_state->sig_handlers[se->signum] == NULL) {
                /* restore old handler, if any */
-               sigaction(se->signum, sig_state->oldact[se->signum], NULL);
-               sig_state->oldact[se->signum] = NULL;
+               if (sig_state->oldact[se->signum]) {
+                       sigaction(se->signum, sig_state->oldact[se->signum], 
NULL);
+                       sig_state->oldact[se->signum] = NULL;
+               }
 #ifdef SA_SIGINFO
                if (se->sa_flags & SA_SIGINFO) {
-                       talloc_free(sig_state->sig_info[se->signum]);
-                       sig_state->sig_info[se->signum] = NULL;
+                       if (sig_state->sig_info[se->signum]) {
+                               talloc_free(sig_state->sig_info[se->signum]);
+                               sig_state->sig_info[se->signum] = NULL;
+                       }
                }
 #endif
        }
@@ -396,3 +402,20 @@ int tevent_common_check_signal(struct tevent_context *ev)
 
        return 1;
 }
+
+void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se)
+{
+       struct tevent_common_signal_list *sl;
+       sl = talloc_get_type(se->additional_data,
+                            struct tevent_common_signal_list);
+
+       tevent_common_signal_list_destructor(sl);
+
+       if (sig_state->sig_handlers[se->signum] == NULL) {
+               if (sig_state->oldact[se->signum]) {
+                       sigaction(se->signum, sig_state->oldact[se->signum], 
NULL);
+                       sig_state->oldact[se->signum] = NULL;
+               }
+       }
+       return;
+}


-- 
Samba Shared Repository

Reply via email to