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.
int sock_close(int fd)
{
- return shutdown(fd, SHUT_RDWR);
+ shutdown(fd, SHUT_RDWR);
+ return close(fd);
}
int sock_accept(int fd)
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;