Force close when dropping a client with a reset using SO_LINGER and give a warning on close failure

This commit is contained in:
Con Kolivas 2014-10-04 03:13:04 +10:00
parent 146e3140f3
commit 7d878bd223
2 changed files with 6 additions and 1 deletions

View File

@ -155,6 +155,10 @@ static int drop_client(conn_instance_t *ci, client_instance_t *client)
ck_wlock(&ci->lock);
fd = client->fd;
if (fd != -1) {
const struct linger so_linger = { 1, 0 };
if (unlikely(setsockopt(client->fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger))))
LOGWARNING("setsockopt failed with errno %d:%s", errno, strerror(errno));
Close(client->fd);
HASH_DEL(clients, client);
HASH_DELETE(fdhh, fdclients, client);

View File

@ -437,7 +437,8 @@ void _Close(int *fd)
if (*fd < 0)
return;
LOGDEBUG("Closing file handle %d", *fd);
close(*fd);
if (unlikely(close(*fd)))
LOGWARNING("Close of fd %d failed with errno %d:%s", *fd, errno, strerror(errno));
*fd = -1;
}