curl_stream: use CURLINFO_ACTIVESOCKET if curl is recent enough#3996
Conversation
|
While I don't like the conditional compile, there's no real alternative I could think of. We definitly cannot drop support for libcurl<7.45.0 but we also have to fix the issue if possible. I also wanted to write a test for #3993, but we actually have no abstractions around |
|
I'd rather check for the flag existing in the headers rather than the version of the library. I would also much prefer for us to create a |
The `CURLINFO_LASTSOCKET` information has been deprecated since curl version 7.45.0 as it may result in an overflow in the returned socket on certain systems, most importantly on 64 bit Windows. Instead, a new call `CURLINFO_ACTIVESOCKET` has been added which instead returns a `curl_socket_t`, which is always sufficiently long to store a socket. As we need to provide backwards compatibility with curl versions smaller than 7.45.0, alias CURLINFO_ACTIVESOCKET to CURLINFO_LASTSOCKET on platforms without CURLINFO_ACTIVESOCKET.
894bb22 to
5cbd526
Compare
|
Well, this is how it looks like when #define'ing things instead. Probably looks a bit nicer. Would be nice if we could simply define things like "CURL_SOCKET_BAD" instead of introducing "GIT_CURL_BADSOCKET", but unfortunately these macros existed earlier than 7.45.0 and have wrong semantics on Windows platforms in that they work with Window's SOCKET type. |
|
Yeah, I do like this better. The version-dependent changes are all together in a single block rather than mixed together with real code. |
The
CURLINFO_LASTSOCKETinformation has been deprecated sincecurl version 7.45.0 as it may result in an overflow in the
returned socket on certain systems, most importantly on 64 bit
Windows. Instead, a new call
CURLINFO_ACTIVESOCKEThas beenadded which instead returns a
curl_socket_t, which is alwayssufficiently long to store a socket.
As the new call has only been introduced with version 7.45.0
which was released in October 2015, we cannot simply remove the
old code but instead are required to conditionally compile based
on libcurl's version.