mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-04 21:46:22 +00:00
Merge pull request #3996 from pks-t/pks/curl-lastsocket-deprecation
curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enough
This commit is contained in:
commit
1db3035d74
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user