From: Jonathan McDowell Date: Tue, 15 Mar 2011 04:51:38 +0000 (+0000) Subject: Actually close the socket in keyd/the keyd backend X-Git-Tag: 0.4.0~33 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=9c96da2b288cebb53388ad4e30adbe9b87f67d91;p=onak.git Actually close the socket in keyd/the keyd backend 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. --- diff --git a/keyd.c b/keyd.c index 7b8a18f..33af8ea 100644 --- 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) diff --git a/keydb_keyd.c b/keydb_keyd.c index dcdcb85..35d2dc4 100644 --- a/keydb_keyd.c +++ b/keydb_keyd.c @@ -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;