]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http: don't hardcode the value of CURL_SOCKOPT_OK
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 13 Sep 2021 14:51:29 +0000 (16:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Sep 2021 17:39:04 +0000 (10:39 -0700)
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>
git-curl-compat.h
http.c

index 7ad87e89ed5d767109d4f5356e54e7ac840b1530..a308bdb3b9b430398237b5ef6da29c9a20082ad8 100644 (file)
  * GIT_CURL_HAVE_X. If multiple similar symbols with the same prefix
  * were defined in the same version we pick one and check for that name.
  *
+ * We may also define a missing CURL_* symbol to its known value, if
+ * doing so is sufficient to add support for it to older versions that
+ * don't have it.
+ *
  * Keep any symbols in date order of when their support was
  * introduced, oldest first, in the official version of cURL library.
  */
 
+/**
+ * CURL_SOCKOPT_OK was added in 7.21.5, released in April 2011.
+ */
+#if LIBCURL_VERSION_NUM < 0x071505
+#define CURL_SOCKOPT_OK 0
+#endif
+
 /**
  * CURLOPT_TCP_KEEPALIVE was added in 7.25.0, released in March 2012.
  */
diff --git a/http.c b/http.c
index 94eefe97089fb1dc80cf2b2288961b18e93812f0..d7c20493d7f3c58dc7a71bb75dd9f7f10d86ebdc 100644 (file)
--- a/http.c
+++ b/http.c
@@ -537,7 +537,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
        if (rc < 0)
                warning_errno("unable to set SO_KEEPALIVE on socket");
 
-       return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
+       return CURL_SOCKOPT_OK;
 }
 
 static void set_curl_keepalive(CURL *c)