Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket option SO_LINGER fix for macOS. #60

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/arch/unix/apr_arch_networkio.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@
#define POLLNVAL 32
#endif

#ifdef SO_LINGER
/* SO_LINGER on macOS works in term of clock ticks */
#ifndef SO_LINGER_SEC
#define SO_LINGER_SEC SO_LINGER
#endif
#endif

typedef struct sock_userdata_t sock_userdata_t;
struct sock_userdata_t {
sock_userdata_t *next;
Expand Down
4 changes: 2 additions & 2 deletions network_io/unix/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ apr_status_t apr_socket_opt_set(apr_socket_t *sock,
}
break;
case APR_SO_LINGER:
#ifdef SO_LINGER
#ifdef SO_LINGER_SEC
if (apr_is_option_set(sock, APR_SO_LINGER) != on) {
struct linger li;
li.l_onoff = on;
li.l_linger = APR_MAX_SECS_TO_LINGER;
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) {
if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER_SEC, (char *) &li, sizeof(struct linger)) == -1) {
return errno;
}
apr_set_option(sock, APR_SO_LINGER, on);
Expand Down