tevent: simplify tevent_cleanup_pending_signal_handlers()
authorStefan Metzmacher <metze@samba.org>
Tue, 22 Jul 2014 10:02:45 +0000 (12:02 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 17 May 2018 07:51:47 +0000 (09:51 +0200)
Calling tevent_signal_destructor() does the same as se->event_ctx is already
NULL.

This also makes sure we correctly cleanup the SA_SIGINFO array.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
lib/tevent/tevent_signal.c

index 1283aab4821159704150469e04bbde73be095f1f..6bb69d77d7a5f0654fcdacde40510fdef7f76e24 100644 (file)
@@ -194,6 +194,7 @@ static int tevent_signal_destructor(struct tevent_signal *se)
                DLIST_REMOVE(ev->signal_events, se);
        }
 
+       se->additional_data = NULL;
        talloc_free(sl);
 
        if (sig_state->sig_handlers[se->signum] == NULL) {
@@ -464,18 +465,7 @@ int tevent_common_check_signal(struct tevent_context *ev)
 
 void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se)
 {
-       struct tevent_common_signal_list *sl =
-               talloc_get_type_abort(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);
-                       talloc_free(sig_state->oldact[se->signum]);
-                       sig_state->oldact[se->signum] = NULL;
-               }
-       }
+       tevent_signal_destructor(se);
+       talloc_set_destructor(se, NULL);
        return;
 }