Add timeout option
This commit is contained in:
12
src/main.c
12
src/main.c
@@ -99,6 +99,7 @@ enum sk_opt {
|
|||||||
sk_defer_accept,
|
sk_defer_accept,
|
||||||
sk_acceptfilter,
|
sk_acceptfilter,
|
||||||
sk_quickack,
|
sk_quickack,
|
||||||
|
sk_user_timeout,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void sk_set (int fd, enum sk_opt opt, const void *val, socklen_t len)
|
static void sk_set (int fd, enum sk_opt opt, const void *val, socklen_t len)
|
||||||
@@ -148,6 +149,11 @@ static void sk_set (int fd, enum sk_opt opt, const void *val, socklen_t len)
|
|||||||
[sk_acceptfilter] = { "SO_ACCEPTFILTER",
|
[sk_acceptfilter] = { "SO_ACCEPTFILTER",
|
||||||
#ifdef SO_ACCEPTFILTER
|
#ifdef SO_ACCEPTFILTER
|
||||||
1, SOL_SOCKET, SO_ACCEPTFILTER,
|
1, SOL_SOCKET, SO_ACCEPTFILTER,
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
[sk_user_timeout] = { "TCP_USER_TIMEOUT",
|
||||||
|
#ifdef TCP_USER_TIMEOUT
|
||||||
|
1, IPPROTO_TCP, TCP_USER_TIMEOUT,
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -867,6 +873,8 @@ int main (int argc, char **argv)
|
|||||||
long retry_const = 0;
|
long retry_const = 0;
|
||||||
long retry_limit = 1000000;
|
long retry_limit = 1000000;
|
||||||
|
|
||||||
|
long user_timeout = 0;
|
||||||
|
|
||||||
struct option ka_opts[] = {
|
struct option ka_opts[] = {
|
||||||
{ "count", &ka_count, option_long },
|
{ "count", &ka_count, option_long },
|
||||||
{ "idle", &ka_idle, option_long },
|
{ "idle", &ka_idle, option_long },
|
||||||
@@ -897,6 +905,7 @@ int main (int argc, char **argv)
|
|||||||
{ "retry", &retry_opts, option_option },
|
{ "retry", &retry_opts, option_option },
|
||||||
{ "daemon", NULL, option_option },
|
{ "daemon", NULL, option_option },
|
||||||
{ "statefile", &statefile, option_str },
|
{ "statefile", &statefile, option_str },
|
||||||
|
{ "timeout", &user_timeout, option_long },
|
||||||
{ "debug", NULL, option_option },
|
{ "debug", NULL, option_option },
|
||||||
{ "version", NULL, option_option },
|
{ "version", NULL, option_option },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
@@ -1078,6 +1087,9 @@ int main (int argc, char **argv)
|
|||||||
sk_set_int(sock.fd, sk_keepintvl, ka_interval);
|
sk_set_int(sock.fd, sk_keepintvl, ka_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user_timeout>0 && user_timeout<=INT_MAX)
|
||||||
|
sk_set_int(sock.fd, sk_user_timeout, user_timeout);
|
||||||
|
|
||||||
sk_set(sock.fd, sk_congestion, congestion, str_len(congestion));
|
sk_set(sock.fd, sk_congestion, congestion, str_len(congestion));
|
||||||
|
|
||||||
switch (gt_setup_crypto(&ctx, sock.fd, listener)) {
|
switch (gt_setup_crypto(&ctx, sock.fd, listener)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user