diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-03-19 11:21:36 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-03-19 11:21:36 +1100 |
commit | 13b6663e23a424473d14324ac229a21e1e90580a (patch) | |
tree | 6107cb53502cdcc8f2b14a426429fbea8b900f32 /lib/tevent | |
parent | 710948c7885b228afe5e1b3bed005f50c57d519b (diff) | |
download | samba-13b6663e23a424473d14324ac229a21e1e90580a.tar.gz samba-13b6663e23a424473d14324ac229a21e1e90580a.tar.bz2 samba-13b6663e23a424473d14324ac229a21e1e90580a.zip |
fixed a logic bug in the tevent nesting code
The event nesting code never triggered as nesting.level was never
greater than 1. The main event loop needs to increase the nesting
level by 1.
I also added a paranoia check to the nesting setup call. The API as
currently written cannot support multiple nesting hooks, so we need to
abort if multiple hooks are tried.
Diffstat (limited to 'lib/tevent')
-rw-r--r-- | lib/tevent/tevent.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c index ba2d93f4b9..56fd6aec7a 100644 --- a/lib/tevent/tevent.c +++ b/lib/tevent/tevent.c @@ -427,6 +427,14 @@ void tevent_loop_set_nesting_hook(struct tevent_context *ev, tevent_nesting_hook hook, void *private_data) { + if (ev->nesting.hook_fn && + (ev->nesting.hook_fn != hook || + ev->nesting.hook_private != private_data)) { + /* the way the nesting hook code is currently written + we cannot support two different nesting hooks at the + same time. */ + tevent_abort(ev, "tevent: Violation of nesting hook rules\n"); + } ev->nesting.hook_fn = hook; ev->nesting.hook_private = private_data; } @@ -593,5 +601,9 @@ int tevent_common_loop_wait(struct tevent_context *ev, */ int _tevent_loop_wait(struct tevent_context *ev, const char *location) { - return ev->ops->loop_wait(ev, location); + int ret; + ev->nesting.level++; + ret = ev->ops->loop_wait(ev, location); + ev->nesting.level--; + return ret; } |