From ff8ace4b99f4fca389a861cd0ffca08e53858577 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 31 Jul 2013 11:31:57 +0200 Subject: [PATCH] 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: Stefan Metzmacher --- lib/tevent/tevent_signal.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c index 0fdf646..8e13d73 100644 --- a/lib/tevent/tevent_signal.c +++ b/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); -- 1.7.9.5