Skip to content

Commit

Permalink
curl: use new library-side TCP_KEEPALIVE options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
falconindy authored and bagder committed Feb 9, 2012
1 parent 705f0f7 commit 2a266c1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 138 deletions.
3 changes: 2 additions & 1 deletion docs/curl.1
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ currently effective on operating systems offering the TCP_KEEPIDLE and
TCP_KEEPINTVL socket options (meaning Linux, recent AIX, HP-UX and more). This
option has no effect if \fI--no-keepalive\fP is used. (Added in 7.18.0)

If this option is used multiple times, the last occurrence sets the amount.
If this option is used multiple times, the last occurrence sets the amount. If
unspecified, the option defaults to 60 seconds.
.IP "--key <key>"
(SSL/SSH) Private key file name. Allows you to provide your private key in this
separate file.
Expand Down
2 changes: 0 additions & 2 deletions src/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ CURL_CFILES = hugehelp.c \
tool_cb_prg.c \
tool_cb_rea.c \
tool_cb_see.c \
tool_cb_skt.c \
tool_cb_wrt.c \
tool_cfgable.c \
tool_convert.c \
Expand Down Expand Up @@ -62,7 +61,6 @@ CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
tool_cb_prg.h \
tool_cb_rea.h \
tool_cb_see.h \
tool_cb_skt.h \
tool_cb_wrt.h \
tool_cfgable.h \
tool_convert.h \
Expand Down
97 changes: 0 additions & 97 deletions src/tool_cb_skt.c

This file was deleted.

35 changes: 0 additions & 35 deletions src/tool_cb_skt.h

This file was deleted.

18 changes: 15 additions & 3 deletions src/tool_operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2a266c1

Please sign in to comment.