summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-02-01 15:50:08 +0100
committerJeremy Allison <jra@samba.org>2013-02-03 06:40:09 +0100
commit570a4b3e22dbddb3f1dc095cc1fe1b6a1f3af069 (patch)
treea142b8db39a8c9e66e255f176392c404928a719a
parente79ad7cff196fd6d9250420d83551fd3ac665b19 (diff)
downloadsamba-570a4b3e22dbddb3f1dc095cc1fe1b6a1f3af069.tar.gz
samba-570a4b3e22dbddb3f1dc095cc1fe1b6a1f3af069.tar.bz2
samba-570a4b3e22dbddb3f1dc095cc1fe1b6a1f3af069.zip
tevent_poll: add poll_event_loop_wait()
We can't use tevent_common_loop_wait() because new fd events will be added to the poll_ev->fresh list instead of ev->fd_events. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sun Feb 3 06:40:09 CET 2013 on sn-devel-104
-rw-r--r--lib/tevent/tevent_poll.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index ac567ce702..5479f2f7cd 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -547,6 +547,35 @@ static int poll_event_loop_once(struct tevent_context *ev,
return poll_event_loop_poll(ev, &tval);
}
+static int poll_event_loop_wait(struct tevent_context *ev,
+ const char *location)
+{
+ struct poll_event_context *poll_ev = talloc_get_type_abort(
+ ev->additional_data, struct poll_event_context);
+
+ /*
+ * loop as long as we have events pending
+ */
+ while (ev->fd_events ||
+ ev->timer_events ||
+ ev->immediate_events ||
+ ev->signal_events ||
+ poll_ev->fresh) {
+ int ret;
+ ret = _tevent_loop_once(ev, location);
+ if (ret != 0) {
+ tevent_debug(ev, TEVENT_DEBUG_FATAL,
+ "_tevent_loop_once() failed: %d - %s\n",
+ ret, strerror(errno));
+ return ret;
+ }
+ }
+
+ tevent_debug(ev, TEVENT_DEBUG_WARNING,
+ "poll_event_loop_wait() out of events\n");
+ return 0;
+}
+
static const struct tevent_ops poll_event_ops = {
.context_init = poll_event_context_init,
.add_fd = poll_event_add_fd,
@@ -557,7 +586,7 @@ static const struct tevent_ops poll_event_ops = {
.schedule_immediate = tevent_common_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = poll_event_loop_once,
- .loop_wait = tevent_common_loop_wait,
+ .loop_wait = poll_event_loop_wait,
};
_PRIVATE_ bool tevent_poll_init(void)
@@ -575,7 +604,7 @@ static const struct tevent_ops poll_event_mt_ops = {
.schedule_immediate = poll_event_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = poll_event_loop_once,
- .loop_wait = tevent_common_loop_wait,
+ .loop_wait = poll_event_loop_wait,
};
_PRIVATE_ bool tevent_poll_mt_init(void)