Blob Blame History Raw
@@ -, +, @@ 
    tevent: Remove the signal pipe if no signal events are around
    
    It makes adding/removing the first/last sigevents a bit more expensive, but it
    will fix tevent_loop_wait not finishing when one signal event was added and
    removed.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10012
    
    Signed-off-by: Volker Lendecke <vl@samba.org>
    Signed-off-by: Stefan Metzmacher <metze@samba.org>
    Reviewed-by: Andreas Schneider <asn@samba.org>
---
 lib/tevent/tevent_signal.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
--- a/lib/tevent/tevent_signal.c	
+++ a/lib/tevent/tevent_signal.c	
@@ -175,7 +175,19 @@ static int tevent_signal_destructor(struct tevent_signal *se)
 			     struct tevent_common_signal_list);
 
 	if (se->event_ctx) {
-		DLIST_REMOVE(se->event_ctx->signal_events, se);
+		struct tevent_context *ev = se->event_ctx;
+
+		DLIST_REMOVE(ev->signal_events, se);
+
+		if (ev->signal_events == NULL && ev->pipe_fde != NULL) {
+			/*
+			 * This was the last signal. Destroy the pipe.
+			 */
+			TALLOC_FREE(ev->pipe_fde);
+
+			close(ev->pipe_fds[0]);
+			close(ev->pipe_fds[1]);
+		}
 	}
 
 	talloc_free(sl);