diff --git a/src/libckpool.c b/src/libckpool.c index 731132ae..32d08a98 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -418,6 +418,13 @@ void keep_sockalive(int fd) setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl)); } +void nolinger_socket(int fd) +{ + const struct linger so_linger = { 1, 0 }; + + setsockopt(fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger)); +} + void noblock_socket(int fd) { int flags = fcntl(fd, F_GETFL, 0); diff --git a/src/libckpool.h b/src/libckpool.h index ce1c8b3a..a769a0ed 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -413,6 +413,7 @@ static inline bool sock_timeout(void) bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port); void keep_sockalive(int fd); +void nolinger_socket(int fd); void noblock_socket(int fd); void block_socket(int fd); void _Close(int *fd);