diff options
author | Volker Lendecke <vl@samba.org> | 2013-07-31 11:31:57 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2013-08-01 13:15:38 +0200 |
commit | 066a642f10cae7980eefb2d8ada3a6c3f5220542 (patch) | |
tree | 5d7f9138435bfb39144bf02075456c5ffd6d166b /lib | |
parent | f9d19c459f01d6e316a4a74a900c69424962eae0 (diff) | |
download | samba-066a642f10cae7980eefb2d8ada3a6c3f5220542.tar.gz samba-066a642f10cae7980eefb2d8ada3a6c3f5220542.tar.bz2 samba-066a642f10cae7980eefb2d8ada3a6c3f5220542.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tevent/tevent_signal.c | 14 |
1 files changed, 13 insertions, 1 deletions
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); |