Skip to content

Commit 32da6e6

Browse files
avargitster
authored andcommitted
http: don't hardcode the value of CURL_SOCKOPT_OK
Use the new git-curl-compat.h header to define CURL_SOCKOPT_OK to its known value if we're on an older curl version that doesn't have it. It was hardcoded in http.c in a15d069 (http: enable keepalive on TCP sockets, 2013-10-12). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e4ff3b6 commit 32da6e6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

git-curl-compat.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,21 @@
2020
* GIT_CURL_HAVE_X. If multiple similar symbols with the same prefix
2121
* were defined in the same version we pick one and check for that name.
2222
*
23+
* We may also define a missing CURL_* symbol to its known value, if
24+
* doing so is sufficient to add support for it to older versions that
25+
* don't have it.
26+
*
2327
* Keep any symbols in date order of when their support was
2428
* introduced, oldest first, in the official version of cURL library.
2529
*/
2630

31+
/**
32+
* CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011.
33+
*/
34+
#if LIBCURL_VERSION_NUM < 0x071505
35+
#define CURL_SOCKOPT_OK 0
36+
#endif
37+
2738
/**
2839
* CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012.
2940
*/

http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
537537
if (rc < 0)
538538
warning_errno("unable to set SO_KEEPALIVE on socket");
539539

540-
return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
540+
return CURL_SOCKOPT_OK;
541541
}
542542

543543
static void set_curl_keepalive(CURL *c)

0 commit comments

Comments
 (0)