tevent: Move rundown of the event pipe
authorVolker Lendecke <vl@samba.org>
Fri, 12 Aug 2016 14:00:56 +0000 (16:00 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 23 Aug 2016 23:33:48 +0000 (01:33 +0200)
Purely cosmetic change: This moves closing the signal/thread event pipe
to where it's opened. This prepares the eventfd support, making the
"magic" for eventfd more obvious.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tevent/tevent.c

index b8178b2d855388fd5dcbb77ce26f231b9480f0e6..d286850c864ca2567fba9bbf5013a996be616026 100644 (file)
@@ -178,6 +178,8 @@ const char **tevent_backend_list(TALLOC_CTX *mem_ctx)
        return list;
 }
 
+static void tevent_common_wakeup_fini(struct tevent_context *ev);
+
 #ifdef HAVE_PTHREAD
 
 static pthread_mutex_t tevent_contexts_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -297,12 +299,7 @@ int tevent_common_context_destructor(struct tevent_context *ev)
                tevent_abort(ev, "threaded contexts exist");
        }
 
-       if (ev->pipe_fde) {
-               talloc_free(ev->pipe_fde);
-               close(ev->pipe_fds[0]);
-               close(ev->pipe_fds[1]);
-               ev->pipe_fde = NULL;
-       }
+       tevent_common_wakeup_fini(ev);
 
        for (fd = ev->fd_events; fd; fd = fn) {
                fn = fd->next;
@@ -896,3 +893,15 @@ int tevent_common_wakeup(struct tevent_context *ev)
 
        return 0;
 }
+
+static void tevent_common_wakeup_fini(struct tevent_context *ev)
+{
+       if (ev->pipe_fde == NULL) {
+               return;
+       }
+
+       TALLOC_FREE(ev->pipe_fde);
+
+       close(ev->pipe_fds[0]);
+       close(ev->pipe_fds[1]);
+}