tevent: Add tevent_common_wakeup_fd()
authorVolker Lendecke <vl@samba.org>
Wed, 7 Sep 2016 17:47:55 +0000 (19:47 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 4 Oct 2016 22:06:21 +0000 (00:06 +0200)
This prepares tevent run-down with active threads.

It has the advantage to not depend on talloc'ed structs. It is needed to make
talloc_free(tevent_context) safe when tevent_threaded_contexts are still
around.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tevent/ABI/tevent-0.9.30.sigs
lib/tevent/tevent.c
lib/tevent/tevent_internal.h

index 66a450e15457b21754f31e4338bba7911f7fae9a..ea179a0d63fb497f3a017729a45c3749fb5a13d5 100644 (file)
@@ -36,6 +36,7 @@ tevent_common_loop_wait: int (struct tevent_context *, const char *)
 tevent_common_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
 tevent_common_threaded_activate_immediate: void (struct tevent_context *)
 tevent_common_wakeup: int (struct tevent_context *)
+tevent_common_wakeup_fd: int (int)
 tevent_common_wakeup_init: int (struct tevent_context *)
 tevent_context_init: struct tevent_context *(TALLOC_CTX *)
 tevent_context_init_byname: struct tevent_context *(TALLOC_CTX *, const char *)
index 87776ec1bb4f48e0e74e7b7e77047d49b207405e..575337d41092efd7efdfa861992fb353dc340ef8 100644 (file)
@@ -902,27 +902,32 @@ int tevent_common_wakeup_init(struct tevent_context *ev)
        return 0;
 }
 
-int tevent_common_wakeup(struct tevent_context *ev)
+int tevent_common_wakeup_fd(int fd)
 {
        ssize_t ret;
 
-       if (ev->wakeup_fde == NULL) {
-               return ENOTCONN;
-       }
-
        do {
 #ifdef HAVE_EVENTFD
                uint64_t val = 1;
-               ret = write(ev->wakeup_fd, &val, sizeof(val));
+               ret = write(fd, &val, sizeof(val));
 #else
                char c = '\0';
-               ret = write(ev->wakeup_fd, &c, 1);
+               ret = write(fd, &c, 1);
 #endif
        } while ((ret == -1) && (errno == EINTR));
 
        return 0;
 }
 
+int tevent_common_wakeup(struct tevent_context *ev)
+{
+       if (ev->wakeup_fde == NULL) {
+               return ENOTCONN;
+       }
+
+       return tevent_common_wakeup_fd(ev->wakeup_fd);
+}
+
 static void tevent_common_wakeup_fini(struct tevent_context *ev)
 {
        if (ev->wakeup_fde == NULL) {
index 84ae5bcfc850bbe432d69b4ccb319d168c306f76..a4af79e85ac4c200f7887dd74b5f81c2e2666ebb 100644 (file)
@@ -357,6 +357,7 @@ void tevent_common_threaded_activate_immediate(struct tevent_context *ev);
 
 bool tevent_common_have_events(struct tevent_context *ev);
 int tevent_common_wakeup_init(struct tevent_context *ev);
+int tevent_common_wakeup_fd(int fd);
 int tevent_common_wakeup(struct tevent_context *ev);
 
 struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,