|
|
@ -127,9 +127,7 @@ static int uh_socket_bind( |
|
|
|
int status; |
|
|
|
int status; |
|
|
|
int bound = 0; |
|
|
|
int bound = 0; |
|
|
|
|
|
|
|
|
|
|
|
int tcp_ka_idl = 1; |
|
|
|
int tcp_ka_idl, tcp_ka_int, tcp_ka_cnt; |
|
|
|
int tcp_ka_int = 1; |
|
|
|
|
|
|
|
int tcp_ka_cnt = 3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct listener *l = NULL; |
|
|
|
struct listener *l = NULL; |
|
|
|
struct addrinfo *addrs = NULL, *p = NULL; |
|
|
|
struct addrinfo *addrs = NULL, *p = NULL; |
|
|
@ -157,6 +155,12 @@ static int uh_socket_bind( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* TCP keep-alive */ |
|
|
|
/* TCP keep-alive */ |
|
|
|
|
|
|
|
if( conf->tcp_keepalive > 0 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
tcp_ka_idl = 1; |
|
|
|
|
|
|
|
tcp_ka_cnt = 3; |
|
|
|
|
|
|
|
tcp_ka_int = conf->tcp_keepalive; |
|
|
|
|
|
|
|
|
|
|
|
if( setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes)) || |
|
|
|
if( setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes)) || |
|
|
|
setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &tcp_ka_idl, sizeof(tcp_ka_idl)) || |
|
|
|
setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &tcp_ka_idl, sizeof(tcp_ka_idl)) || |
|
|
|
setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, &tcp_ka_int, sizeof(tcp_ka_int)) || |
|
|
|
setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, &tcp_ka_int, sizeof(tcp_ka_int)) || |
|
|
@ -165,6 +169,7 @@ static int uh_socket_bind( |
|
|
|
fprintf(stderr, "Notice: Unable to enable TCP keep-alive: %s\n", |
|
|
|
fprintf(stderr, "Notice: Unable to enable TCP keep-alive: %s\n", |
|
|
|
strerror(errno)); |
|
|
|
strerror(errno)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* required to get parallel v4 + v6 working */ |
|
|
|
/* required to get parallel v4 + v6 working */ |
|
|
|
if( p->ai_family == AF_INET6 ) |
|
|
|
if( p->ai_family == AF_INET6 ) |
|
|
@ -619,7 +624,7 @@ static void uh_mainloop(struct config *conf, fd_set serv_fds, int max_fd) |
|
|
|
int main (int argc, char **argv) |
|
|
|
int main (int argc, char **argv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* master file descriptor list */ |
|
|
|
/* master file descriptor list */ |
|
|
|
fd_set used_fds, serv_fds, read_fds; |
|
|
|
fd_set serv_fds; |
|
|
|
|
|
|
|
|
|
|
|
/* working structs */ |
|
|
|
/* working structs */ |
|
|
|
struct addrinfo hints; |
|
|
|
struct addrinfo hints; |
|
|
@ -650,10 +655,7 @@ int main (int argc, char **argv) |
|
|
|
void *lib; |
|
|
|
void *lib; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* clear the master and temp sets */ |
|
|
|
|
|
|
|
FD_ZERO(&used_fds); |
|
|
|
|
|
|
|
FD_ZERO(&serv_fds); |
|
|
|
FD_ZERO(&serv_fds); |
|
|
|
FD_ZERO(&read_fds); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* handle SIGPIPE, SIGINT, SIGTERM, SIGCHLD */ |
|
|
|
/* handle SIGPIPE, SIGINT, SIGTERM, SIGCHLD */ |
|
|
|
sa.sa_flags = 0; |
|
|
|
sa.sa_flags = 0; |
|
|
@ -722,7 +724,7 @@ int main (int argc, char **argv) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
while( (opt = getopt(argc, argv, |
|
|
|
while( (opt = getopt(argc, argv, |
|
|
|
"fSDRC:K:E:I:p:s:h:c:l:L:d:r:m:x:i:t:T:")) > 0 |
|
|
|
"fSDRC:K:E:I:p:s:h:c:l:L:d:r:m:x:i:t:T:A:")) > 0 |
|
|
|
) { |
|
|
|
) { |
|
|
|
switch(opt) |
|
|
|
switch(opt) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -896,6 +898,11 @@ int main (int argc, char **argv) |
|
|
|
conf.network_timeout = atoi(optarg); |
|
|
|
conf.network_timeout = atoi(optarg); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* tcp keep-alive */ |
|
|
|
|
|
|
|
case 'A': |
|
|
|
|
|
|
|
conf.tcp_keepalive = atoi(optarg); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
/* no fork */ |
|
|
|
/* no fork */ |
|
|
|
case 'f': |
|
|
|
case 'f': |
|
|
|
nofork = 1; |
|
|
|
nofork = 1; |
|
|
|