]> the.earth.li Git - onak.git/commitdiff
Actually close the socket in keyd/the keyd backend
authorJonathan McDowell <noodles@earth.li>
Tue, 15 Mar 2011 04:51:38 +0000 (04:51 +0000)
committerJonathan McDowell <noodles@earth.li>
Tue, 15 Mar 2011 04:51:38 +0000 (04:51 +0000)
  We were calling shutdown() on the socket, but this isn't sufficient -
  we need to call close() as well. Otherwise we end up leaking sockets
  and eventually keyd can no longer service requests.

keyd.c
keydb_keyd.c

diff --git a/keyd.c b/keyd.c
index 7b8a18fa5f6f12f74f388037731df34f24dcb5ea..33af8ea0e3935768e75a021d9c2bd781db163383 100644 (file)
--- a/keyd.c
+++ b/keyd.c
@@ -311,7 +311,8 @@ int sock_do(int fd)
 
 int sock_close(int fd)
 {
-       return shutdown(fd, SHUT_RDWR);
+       shutdown(fd, SHUT_RDWR);
+       return close(fd);
 }
 
 int sock_accept(int fd)
index dcdcb85f3669eeb6919a92de3dedefd7cec5a3cd..35d2dc4cab504d388a5e2d3e7bcd4cd693c6fa93 100644 (file)
@@ -116,6 +116,10 @@ static void keyd_cleanupdb(void)
                logthing(LOGTHING_NOTICE, "Error shutting down socket: %d",
                                errno);
        }
+       if (close(keyd_fd) < 0) {
+               logthing(LOGTHING_NOTICE, "Error closing down socket: %d",
+                               errno);
+       }
        keyd_fd = -1;
 
        return;