diff options
Diffstat (limited to 'lib/tevent')
-rw-r--r-- | lib/tevent/tevent.c | 15 | ||||
-rw-r--r-- | lib/tevent/tevent.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c index a0ee208663..ceae534c9b 100644 --- a/lib/tevent/tevent.c +++ b/lib/tevent/tevent.c @@ -616,3 +616,18 @@ int _tevent_loop_wait(struct tevent_context *ev, const char *location) { return ev->ops->loop_wait(ev, location); } + + +/* + re-initialise a tevent context. This leaves you with the same + event context, but all events are wiped and the structure is + re-initialised. This is most useful after a fork() + + zero is returned on success, non-zero on failure +*/ +int tevent_re_initialise(struct tevent_context *ev) +{ + tevent_common_context_destructor(ev); + + return ev->ops->context_init(ev); +} diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h index e318a4bf1d..ad1f2c9cc3 100644 --- a/lib/tevent/tevent.h +++ b/lib/tevent/tevent.h @@ -366,6 +366,8 @@ int _tevent_loop_until(struct tevent_context *ev, _tevent_loop_until(ev, finished, private_data, __location__) #endif +int tevent_re_initialise(struct tevent_context *ev); + /** * The following structure and registration functions are exclusively |