diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-02-09 19:04:08 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-02-09 19:05:40 +0100 |
commit | 2a266c1c7c075f9faced0248ed3f870dac1fc749 (patch) | |
tree | 8d4b40101b70e2110c4e3101012765086ab3baa3 /src/tool_operate.c | |
parent | 705f0f7a5b6120bb783d139c9266b285a4c8acd8 (diff) | |
download | curl-2a266c1c7c075f9faced0248ed3f870dac1fc749.tar.gz |
curl: use new library-side TCP_KEEPALIVE options
Use the new library CURLOPT_TCP_KEEPALIVE rather than disabling this via
the sockopt callback. If --keepalive-time is used, apply the value to
CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL.
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r-- | src/tool_operate.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index e113ecdfc..1557e6256 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -41,6 +41,10 @@ # include <locale.h> #endif +#ifdef HAVE_NETINET_TCP_H +# include <netinet/tcp.h> +#endif + #include "rawstr.h" #define ENABLE_CURLX_PRINTF @@ -54,7 +58,6 @@ #include "tool_cb_prg.h" #include "tool_cb_rea.h" #include "tool_cb_see.h" -#include "tool_cb_skt.h" #include "tool_cb_wrt.h" #include "tool_dirhie.h" #include "tool_doswin.h" @@ -1165,9 +1168,18 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) /* curl 7.17.1 */ if(!config->nokeepalive) { - my_setopt(curl, CURLOPT_SOCKOPTFUNCTION, tool_sockopt_cb); - my_setopt(curl, CURLOPT_SOCKOPTDATA, config); + my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); + if(config->alivetime != 0) { +#if !defined(TCP_KEEPIDLE) || !defined(TCP_KEEPINTVL) + warnf(config, "Keep-alive functionality somewhat crippled due to " + "missing support in your operating system!\n"); +#endif + my_setopt(curl, CURLOPT_TCP_KEEPIDLE, config->alivetime); + my_setopt(curl, CURLOPT_TCP_KEEPINTVL, config->alivetime); + } } + else + my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 0L); /* curl 7.20.0 */ if(config->tftp_blksize) |