Skip to content

Commit bfdd259

Browse files
ttaylorrgitster
authored andcommitted
http.c: inline set_curl_keepalive()
At the end of `get_curl_handle()` we call `set_curl_keepalive()` to enable TCP keepalive probes on our CURL handle. `set_curl_keepalive()` dates back to 47ce115 (http: use curl's tcp keepalive if available, 2013-10-14), which conditionally compiled different variants of `set_curl_keepalive()` depending on what version of curl we were compiled with[^1]. As of f7c0940 (git-curl-compat: remove check for curl 7.25.0, 2024-10-23), we no longer conditionally compile `set_curl_keepalive()` since we no longer support pre-7.25.0 versions of curl. But the version of that function that we kept is really just a thin wrapper around setting the TCP_KEEPALIVE option, so there's no reason to keep it in its own function. Inline the definition of `set_curl_keepalive()` to within `get_curl_handle()` so that the setup of our CURL handle is self-contained. [1]: The details are spelled out in 47ce115, but the gist is curl 7.25.0 and newer use CURLOPT_TCP_KEEPALIVE, older versions use CURLOPT_SOCKOPTFUNCTION with a custom callback, and older versions that predate even that option do nothing. Signed-off-by: Taylor Blau <[email protected]> Acked-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 572795c commit bfdd259

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

http.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,6 @@ static int has_proxy_cert_password(void)
704704
return 1;
705705
}
706706

707-
static void set_curl_keepalive(CURL *c)
708-
{
709-
curl_easy_setopt(c, CURLOPT_TCP_KEEPALIVE, 1);
710-
}
711707

712708
/* Return 1 if redactions have been made, 0 otherwise. */
713709
static int redact_sensitive_header(struct strbuf *header, size_t offset)
@@ -1242,7 +1238,7 @@ static CURL *get_curl_handle(void)
12421238
}
12431239
init_curl_proxy_auth(result);
12441240

1245-
set_curl_keepalive(result);
1241+
curl_easy_setopt(result, CURLOPT_TCP_KEEPALIVE, 1);
12461242

12471243
return result;
12481244
}

0 commit comments

Comments
 (0)