summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-03-01 09:27:29 +0100
committerJeremy Allison <jra@samba.org>2013-03-01 11:58:20 -0800
commitd9a69e6dbf61cffd6be473a460f6671573aa8564 (patch)
tree96e44c5c6f26a2b77b875609fe49b40fb782f655 /source3
parent8ac431a22e45611d4bbded67c4c8bd864c343a8f (diff)
downloadsamba-d9a69e6dbf61cffd6be473a460f6671573aa8564.tar.gz
samba-d9a69e6dbf61cffd6be473a460f6671573aa8564.tar.bz2
samba-d9a69e6dbf61cffd6be473a460f6671573aa8564.zip
s3:lib/events: make use of tevent_common_loop_timer_delay()
This is critical as we also use tevent_common_add_timer(). And if the common code does internal changes, it may affects both tevent_common_add_timer() and tevent_common_loop_timer_delay() together! Without this we rely on a specific behavior and version of tevent. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/events.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/source3/lib/events.c b/source3/lib/events.c
index 0a8039ac6e..62aa4d973e 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -182,7 +182,6 @@ bool run_events_poll(struct tevent_context *ev, int pollrtn,
struct tevent_poll_private *state;
int *pollfd_idx;
struct tevent_fd *fde;
- struct timeval now;
if (ev->signal_events &&
tevent_common_check_signal(ev)) {
@@ -194,37 +193,14 @@ bool run_events_poll(struct tevent_context *ev, int pollrtn,
return true;
}
- GetTimeOfDay(&now);
-
- if ((ev->timer_events != NULL)
- && (timeval_compare(&now, &ev->timer_events->next_event) >= 0)) {
- /* this older events system did not auto-free timed
- events on running them, and had a race condition
- where the event could be called twice if the
- talloc_free of the te happened after the callback
- made a call which invoked the event loop. To avoid
- this while still allowing old code which frees the
- te, we need to create a temporary context which
- will be used to ensure the te is freed. We also
- remove the te from the timed event list before we
- call the handler, to ensure we can't loop */
-
- struct tevent_timer *te = ev->timer_events;
- TALLOC_CTX *tmp_ctx = talloc_new(ev);
-
- DEBUG(10, ("Running timed event \"%s\" %p\n",
- ev->timer_events->handler_name, ev->timer_events));
-
- DLIST_REMOVE(ev->timer_events, te);
- talloc_steal(tmp_ctx, te);
-
- te->handler(ev, te, now, te->private_data);
+ if (pollrtn <= 0) {
+ struct timeval tval;
- talloc_free(tmp_ctx);
- return true;
- }
+ tval = tevent_common_loop_timer_delay(ev);
+ if (tevent_timeval_is_zero(&tval)) {
+ return true;
+ }
- if (pollrtn <= 0) {
/*
* No fd ready
*/