talloc: use the system pytalloc-util for python3 as well
[sfrench/samba-autobuild/.git] / lib / tevent / tevent_epoll.c
index 1ec97c5f7193867e332257f5487ff90ed7232365..4147c67af2a014ed16b829c7730ac0f1fbb93a34 100644 (file)
@@ -116,23 +116,15 @@ static int epoll_wait_panic_fallback(struct epoll_event_context *epoll_ev,
 /*
   called to set the panic fallback function.
 */
-_PRIVATE_ bool tevent_epoll_set_panic_fallback(struct tevent_context *ev,
+_PRIVATE_ void tevent_epoll_set_panic_fallback(struct tevent_context *ev,
                                bool (*panic_fallback)(struct tevent_context *ev,
                                                       bool replay))
 {
-       struct epoll_event_context *epoll_ev;
-
-       if (ev->additional_data == NULL) {
-               return false;
-       }
+       struct epoll_event_context *epoll_ev =
+               talloc_get_type_abort(ev->additional_data,
+               struct epoll_event_context);
 
-       epoll_ev = talloc_get_type(ev->additional_data,
-                               struct epoll_event_context);
-       if (epoll_ev == NULL) {
-               return false;
-       }
        epoll_ev->panic_fallback = panic_fallback;
-       return true;
 }
 
 /*
@@ -224,7 +216,7 @@ static void epoll_update_event(struct epoll_event_context *epoll_ev, struct teve
 
 /*
   reopen the epoll handle when our pid changes
-  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an 
+  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
   demonstration of why this is needed
  */
 static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
@@ -669,7 +661,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
        }
 
        for (i=0;i<ret;i++) {
-               struct tevent_fd *fde = talloc_get_type(events[i].data.ptr, 
+               struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
                                                       struct tevent_fd);
                uint16_t flags = 0;
                struct tevent_fd *mpx_fde = NULL;
@@ -843,8 +835,9 @@ static struct tevent_fd *epoll_event_add_fd(struct tevent_context *ev, TALLOC_CT
                                            const char *handler_name,
                                            const char *location)
 {
-       struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
-                                                          struct epoll_event_context);
+       struct epoll_event_context *epoll_ev =
+               talloc_get_type_abort(ev->additional_data,
+               struct epoll_event_context);
        struct tevent_fd *fde;
        bool panic_triggered = false;
 
@@ -879,7 +872,8 @@ static void epoll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
        if (fde->flags == flags) return;
 
        ev = fde->event_ctx;
-       epoll_ev = talloc_get_type(ev->additional_data, struct epoll_event_context);
+       epoll_ev = talloc_get_type_abort(ev->additional_data,
+                                        struct epoll_event_context);
 
        fde->flags = flags;
 
@@ -894,12 +888,13 @@ static void epoll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 }
 
 /*
-  do a single event loop using the events defined in ev 
+  do a single event loop using the events defined in ev
 */
 static int epoll_event_loop_once(struct tevent_context *ev, const char *location)
 {
-       struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
-                                                          struct epoll_event_context);
+       struct epoll_event_context *epoll_ev =
+               talloc_get_type_abort(ev->additional_data,
+               struct epoll_event_context);
        struct timeval tval;
        bool panic_triggered = false;
 
@@ -908,6 +903,10 @@ static int epoll_event_loop_once(struct tevent_context *ev, const char *location
                return 0;
        }
 
+       if (ev->threaded_contexts != NULL) {
+               tevent_common_threaded_activate_immediate(ev);
+       }
+
        if (ev->immediate_events &&
            tevent_common_loop_immediate(ev)) {
                return 0;
@@ -937,7 +936,7 @@ static const struct tevent_ops epoll_event_ops = {
        .set_fd_close_fn        = tevent_common_fd_set_close_fn,
        .get_fd_flags           = tevent_common_fd_get_flags,
        .set_fd_flags           = epoll_event_set_fd_flags,
-       .add_timer              = tevent_common_add_timer,
+       .add_timer              = tevent_common_add_timer_v2,
        .schedule_immediate     = tevent_common_schedule_immediate,
        .add_signal             = tevent_common_add_signal,
        .loop_once              = epoll_event_loop_once,