Skip to content

Commit

Permalink
Use CURLINFO_ACTIVESOCKET where available
Browse files Browse the repository at this point in the history
Closes pooler#159.
  • Loading branch information
pooler committed Jun 24, 2020
1 parent f9ef30f commit af2501c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit af2501c

Please sign in to comment.