From 066a642f10cae7980eefb2d8ada3a6c3f5220542 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 31 Jul 2013 11:31:57 +0200 Subject: 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 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- lib/tevent/tevent_signal.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/tevent/tevent_signal.c') diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c index 0fdf646c8d..8e13d7351f 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); -- cgit