Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.0
-
None
-
Windows XP, Visual Studio 2005, libcurl 7.17.1
Description
I did some work to backport the new libcurl NetAccessor to plugin to Xerces 2.8.0, and found some bugs in the process that are also broken for 3.0. The use of fd_set seems to be broken. Arrays of fd_sets (which are themselves length-prefixed arrays of sockets) are being passed into curl_multi_fdset without being zeroed out with FD_ZERO first, which causes a crash because the socket count on input is wrong.
I believe the correct code should be to declare only a single set of fd_set variables, not arrays, and call FD_ZERO first, then pass the address of the variables into curl_multi_fdset and the select call below.
This seems to work for me under simple test cases.
Specifically the loop at the end looks like:
// If there is no further data to read, and we haven't
// read any yet on this invocation, call select to wait for data
if (!tryAgain && fBytesRead == 0)
A better implementation of this would be to dump the multi libcurl API, which is far more complicated than this use case requires, but I didn't have time to try that for now.