From af2501c2c7babf958549d0d10a279f75c47a35b3 Mon Sep 17 00:00:00 2001 From: pooler Date: Wed, 24 Jun 2020 17:22:36 +0000 Subject: [PATCH] Use CURLINFO_ACTIVESOCKET where available Closes #159. --- util.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util.c b/util.c index 23e073503..5fd90af2c 100644 --- a/util.c +++ b/util.c @@ -1064,7 +1064,7 @@ char *stratum_recv_line(struct stratum_ctx *sctx) return sret; } -#if LIBCURL_VERSION_NUM >= 0x071101 +#if LIBCURL_VERSION_NUM >= 0x071101 && LIBCURL_VERSION_NUM < 0x072d00 static curl_socket_t opensocket_grab_cb(void *clientp, curlsocktype purpose, struct curl_sockaddr *addr) { @@ -1122,7 +1122,7 @@ bool stratum_connect(struct stratum_ctx *sctx, const char *url) #if LIBCURL_VERSION_NUM >= 0x070f06 curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_keepalive_cb); #endif -#if LIBCURL_VERSION_NUM >= 0x071101 +#if LIBCURL_VERSION_NUM >= 0x071101 && LIBCURL_VERSION_NUM < 0x072d00 curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket_grab_cb); curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sctx->sock); #endif @@ -1136,7 +1136,9 @@ bool stratum_connect(struct stratum_ctx *sctx, const char *url) return false; } -#if LIBCURL_VERSION_NUM < 0x071101 +#if LIBCURL_VERSION_NUM >= 0x072d00 + curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sctx->sock); +#elif LIBCURL_VERSION_NUM < 0x071101 /* CURLINFO_LASTSOCKET is broken on Win64; only use it as a last resort */ curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, (long *)&sctx->sock); #endif