tevent_loop_wait() never finishes
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Jul 31 03:33:40 MDT 2013
On Mon, Jun 24, 2013 at 02:52:05PM +0200, Pavel Březina wrote:
> Hi,
> I've run across a problem where I don't have any custom event
> handlers registered with tevent, but the program gets stuck in
> tevent_loop_wait().
Does the attached (untested!) patch fix it?
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From d3500a4e1e683fc6071c5cf7560deaeda71763f3 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
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.
---
lib/tevent/tevent_signal.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index 0fdf646..23bcdf7 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -175,7 +175,25 @@ 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) {
+ /*
+ * This was the last signal. Destroy the pipe.
+ */
+ TALLOC_FREE(ev->pipe_fde);
+
+ if (ev->pipe_fds[0] != -1) {
+ close(ev->pipe_fds[0]);
+ ev->pipe_fds[0] = -1;
+ }
+ if (ev->pipe_fds[1] != -1) {
+ close(ev->pipe_fds[1]);
+ ev->pipe_fds[1] = -1;
+ }
+ }
}
talloc_free(sl);
--
1.7.9.5
More information about the samba-technical
mailing list