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 a15d069a198 (http: enable keepalive on TCP sockets, 2013-10-12). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Sep 13, 2021 at 16:51 UTC
32da6e6dafb1db563b6fa1ec80a21d58268e4ad1
2 files changed
+12
-1
git-curl-compat.h
+11
@@ -20,10 +20,21 @@
20
* GIT_CURL_HAVE_X. If multiple similar symbols with the same prefix
21
* were defined in the same version we pick one and check for that name.
22
*
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
+ *
27
* Keep any symbols in date order of when their support was
28
* introduced, oldest first, in the official version of cURL library.
29
*/
30
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
+
38
/**
39
* CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012.
40
*/
http.c
+1
-1
@@ -537,7 +537,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
537
if (rc < 0)
538
warning_errno("unable to set SO_KEEPALIVE on socket");
539
540
- return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
540
+ return CURL_SOCKOPT_OK;
541
}
542
543
static void set_curl_keepalive(CURL *c)