Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2016-11-07 10:21:22 -0500
committerAllan McRae <allan@archlinux.org>2016-12-05 15:20:08 +1000
commit7114ca6208d3dffe685b994f0802c90727303fc8 (patch)
tree8751c3c4648a20b53b9d500bf8b00e6a6a558b85 /lib/libalpm
parent263e65dbb3c841c70766e9509f0dcbdd1186c366 (diff)
dload: use curl's keepalive mechanism
This does exactly the same thing as it code it replaces, but punt to curl to do it for brevity. Requires curl 7.25.0, which we already cover. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/dload.c46
1 files changed, 3 insertions, 43 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 9d803580..ccd70d99 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -246,47 +246,6 @@ static size_t dload_parseheader_cb(void *ptr, size_t size, size_t nmemb, void *u
return realsize;
}
-static int dload_sockopt_cb(void *userdata, curl_socket_t curlfd,
- curlsocktype purpose)
-{
- alpm_handle_t *handle = userdata;
- int optval = 1;
-
- /* this whole method is to prevent FTP control connections from going sour
- * during a long data transfer; crappy firewalls love to drop otherwise idle
- * connections if there is no traffic. */
- if(purpose != CURLSOCKTYPE_IPCXN) {
- return 0;
- }
-
- /* don't abort operation if any setsockopt fails, just log to debug */
- if(setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval,
- sizeof(optval)) < 0) {
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "Failed to set SO_KEEPALIVE on fd %d\n", curlfd);
- }
- else {
-#ifdef TCP_KEEPIDLE
- optval = 60;
- if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&optval,
- sizeof(optval)) < 0) {
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "Failed to set TCP_KEEPIDLE on fd %d\n", curlfd);
- }
-#endif
-#ifdef TCP_KEEPINTVL
- optval = 60;
- if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&optval,
- sizeof(optval)) < 0) {
- _alpm_log(handle, ALPM_LOG_DEBUG,
- "Failed to set TCP_KEEPINTVL on fd %d\n", curlfd);
- }
-#endif
- }
-
- return 0;
-}
-
static void curl_set_handle_opts(struct dload_payload *payload,
CURL *curl, char *error_buffer)
{
@@ -310,8 +269,9 @@ static void curl_set_handle_opts(struct dload_payload *payload,
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, dload_parseheader_cb);
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, (void *)payload);
curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
- curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, dload_sockopt_cb);
- curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, (void *)handle);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 60L);
+ curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
_alpm_log(handle, ALPM_LOG_DEBUG, "url: %s\n", payload->fileurl);