summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlosmn@github.com>2016-11-15 12:18:49 +0100
committerGitHub <noreply@github.com>2016-11-15 12:18:49 +0100
commit1db3035d74a8f734d65b4e779d3e4b22cfd90ebb (patch)
treee99c52be083c106983cda0321bd39c9da6b93d55
parentf5ea9d4a5fca10089e79cf6149364f5013304192 (diff)
parent5cbd52607c7488d7b9680e743887b08926a24710 (diff)
downloadlibgit2-1db3035d74a8f734d65b4e779d3e4b22cfd90ebb.tar.gz
Merge pull request #3996 from pks-t/pks/curl-lastsocket-deprecation
curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enough
-rw-r--r--src/curl_stream.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/curl_stream.c b/src/curl_stream.c
index 3a3f364b2..4e0455cca 100644
--- a/src/curl_stream.c
+++ b/src/curl_stream.c
@@ -15,6 +15,16 @@
#include "vector.h"
#include "proxy.h"
+/* This is for backwards compatibility with curl<7.45.0. */
+#ifndef CURLINFO_ACTIVESOCKET
+# define CURLINFO_ACTIVESOCKET CURLINFO_LASTSOCKET
+# define GIT_CURL_BADSOCKET -1
+# define git_activesocket_t long
+#else
+# define GIT_CURL_BADSOCKET CURL_SOCKET_BAD
+# define git_activesocket_t curl_socket_t
+#endif
+
typedef struct {
git_stream parent;
CURL *handle;
@@ -87,7 +97,8 @@ static int ask_and_apply_proxy_creds(curl_stream *s)
static int curls_connect(git_stream *stream)
{
curl_stream *s = (curl_stream *) stream;
- long sockextr, connect_last = 0;
+ git_activesocket_t sockextr;
+ long connect_last = 0;
int failed_cert = 0, error;
bool retry_connect;
CURLcode res;
@@ -117,11 +128,11 @@ static int curls_connect(git_stream *stream)
if (res == CURLE_PEER_FAILED_VERIFICATION)
failed_cert = 1;
- if ((res = curl_easy_getinfo(s->handle, CURLINFO_LASTSOCKET, &sockextr)) != CURLE_OK) {
+ if ((res = curl_easy_getinfo(s->handle, CURLINFO_ACTIVESOCKET, &sockextr)) != CURLE_OK) {
return seterr_curl(s);
}
- if (sockextr == -1) {
+ if (sockextr == GIT_CURL_BADSOCKET) {
giterr_set(GITERR_NET, "curl socket is no longer valid");
return -1;
}