diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-13 03:55:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:22:59 -0500 |
commit | b433d615370dfad05befb1ca524c2cbc0d4e64bc (patch) | |
tree | b79fa364d70222d90d470e446a9ed3b0d98d0aa3 /source4 | |
parent | d1291dacbd8c5e736e7d8288fb00b5368288b711 (diff) | |
download | samba-b433d615370dfad05befb1ca524c2cbc0d4e64bc.tar.gz samba-b433d615370dfad05befb1ca524c2cbc0d4e64bc.tar.bz2 samba-b433d615370dfad05befb1ca524c2cbc0d4e64bc.zip |
r8409: fixed another error found on netbsd.
some of our torture code does its own timeout processing, which means
there is no event timer in the event context. To fix this gererically
I have added a 30 second timout to all select/epoll calls so the
callers timeout loop is guaranteed to run eventually
(This used to be commit 01e5aa146439f2dbf6c4133a0b5d910383a6576b)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/events/events_standard.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c index a867f86801..5a64a42b28 100644 --- a/source4/lib/events/events_standard.c +++ b/source4/lib/events/events_standard.c @@ -335,6 +335,10 @@ static void std_event_loop_timer(struct event_context *ev) struct timeval t = timeval_current(); struct timed_event *te = std_ev->timed_events; + if (te == NULL) { + return; + } + te->next_event = timeval_zero(); te->handler(ev, te, t, te->private_data); @@ -479,31 +483,32 @@ static int std_event_loop_once(struct event_context *ev) { struct std_event_context *std_ev = talloc_get_type(ev->additional_data, struct std_event_context); - struct timeval tval, *tvalp; - - tvalp = NULL; + struct timeval tval; /* work out the right timeout for all timed events */ if (std_ev->timed_events) { struct timeval t = timeval_current(); - tval = timeval_diff(&std_ev->timed_events->next_event, &t); - tvalp = &tval; - if (timeval_is_zero(tvalp)) { + if (timeval_is_zero(&tval)) { std_event_loop_timer(ev); return 0; } + } else { + /* have a default tick time of 30 seconds. This guarantees + that code that uses its own timeout checking will be + able to proceeed eventually */ + tval = timeval_set(30, 0); } #if WITH_EPOLL if (std_ev->epoll_fd != -1) { - if (std_event_loop_epoll(ev, tvalp) == 0) { + if (std_event_loop_epoll(ev, &tval) == 0) { return 0; } } #endif - return std_event_loop_select(ev, tvalp); + return std_event_loop_select(ev, &tval); } /* |