cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLINFO_LASTSOCKET Windows 64 patch

From: Razvan Cojocaru <rcojocaru_at_bitdefender.com>
Date: Fri, 14 Aug 2015 16:13:27 +0300

Hello,

Known bug #76 [1] states that "the SOCKET type in Win64 is 64 bits large
(and thus so is curl_socket_t on that platform), and long is only 32
bits. It makes it impossible for curl_easy_getinfo() to return a socket
properly with the CURLINFO_LASTSOCKET option as for all other operating
systems."

Looking at the code (I'm using curl-7.43.0), could we change the code in
lib/getinfo.c:

168 case CURLINFO_LASTSOCKET:
169 sockfd = Curl_getconnectinfo(data, NULL);
170
171 /* note: this is not a good conversion for systems with 64 bit
sockets and
172 32 bit longs */
173 if(sockfd != CURL_SOCKET_BAD)
174 *param_longp = (long)sockfd;
175 else
176 /* this interface is documented to return -1 in case of
badness, which
177 may not be the same as the CURL_SOCKET_BAD value */
178 *param_longp = -1;
179 break;

to have line 174 say:

174 *(long long *)param_longp = sockfd;

line 178 say:

178 *(long long *)param_longp = -1;

and simply document that for CURLINFO_LASTSOCKET only, we should pass a
long long pointer to curl_easy_getinfo()? If I'm not mistaken, this
would make libcurl perfectly usable with a CURLOPT_CONNECT_ONLY
scenario, on all platforms.

[1] http://curl.haxx.se/docs/knownbugs.html

Thanks,
Razvan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-08-14