]> granicus.if.org Git - libevent/commitdiff
Avoid a spurious close(-1) on Linux
authorNick Mathewson <nickm@torproject.org>
Fri, 12 Mar 2010 23:35:15 +0000 (18:35 -0500)
committerNick Mathewson <nickm@torproject.org>
Sat, 13 Mar 2010 05:31:14 +0000 (00:31 -0500)
On Linux, we use only one fd to do main-thread signaling (since we have
eventfd()), so we don't need to close th_notify_fd[1] as we would if we were
using a socketpair.

event.c

diff --git a/event.c b/event.c
index 4e3a84f709b75777c37988a0d645cc473781e92d..469da7e651e5f0baa9bd6e22f4e298c7f146c5f9 100644 (file)
--- a/event.c
+++ b/event.c
@@ -648,7 +648,8 @@ event_base_free(struct event_base *base)
        if (base->th_notify_fd[0] != -1) {
                event_del(&base->th_notify);
                EVUTIL_CLOSESOCKET(base->th_notify_fd[0]);
-               EVUTIL_CLOSESOCKET(base->th_notify_fd[1]);
+               if (base->th_notify_fd[1] != -1)
+                       EVUTIL_CLOSESOCKET(base->th_notify_fd[1]);
                base->th_notify_fd[0] = -1;
                base->th_notify_fd[1] = -1;
                event_debug_unassign(&base->th_notify);