tevent: add std_event_loop_wait()
authorStefan Metzmacher <metze@samba.org>
Sun, 17 Feb 2013 15:41:41 +0000 (16:41 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 1 Mar 2013 17:51:53 +0000 (18:51 +0100)
We also need to fallback in tevent_loop_wait()
otherwise we might miss events in the poll->fresh list.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
lib/tevent/tevent_standard.c

index a9c6170320f2cbe8bd9fc7bfba717e30e72d0727..258499484a276e90e0b4bf0cc2b67e8cd0c5a4e4 100644 (file)
@@ -127,6 +127,22 @@ static int std_event_loop_once(struct tevent_context *ev, const char *location)
        return glue->poll_ops->loop_once(ev, location);
 }
 
+static int std_event_loop_wait(struct tevent_context *ev, const char *location)
+{
+       void *glue_ptr = talloc_parent(ev->ops);
+       struct std_event_glue *glue =
+               talloc_get_type_abort(glue_ptr,
+               struct std_event_glue);
+       int ret;
+
+       ret = glue->epoll_ops->loop_wait(ev, location);
+       if (glue->epoll_ops != NULL) {
+               /* No fallback */
+               return ret;
+       }
+
+       return glue->poll_ops->loop_wait(ev, location);
+}
 /*
   Initialize the epoll backend and allow it to call a
   switch function if epoll fails at runtime.
@@ -183,6 +199,7 @@ static int std_event_context_init(struct tevent_context *ev)
                *glue->glue_ops = *glue->epoll_ops;
                glue->glue_ops->context_init = std_event_context_init;
                glue->glue_ops->loop_once = std_event_loop_once;
+               glue->glue_ops->loop_wait = std_event_loop_wait;
 
                ret = glue->epoll_ops->context_init(ev);
                if (ret == -1) {