[ 
https://issues.apache.org/jira/browse/XERCESC-1756?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alberto Massari resolved XERCESC-1756.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 3.0.0
         Assignee: Alberto Massari

I have aligned the code with the fopen.c sample that ships with libcurl 
(including the maxfd+1 expression in the call to select)

> CurlURLInputStream misusing fd_set structure in libcurl and select calls
> ------------------------------------------------------------------------
>
>                 Key: XERCESC-1756
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1756
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Miscellaneous
>    Affects Versions: 3.0.0
>         Environment: Windows XP, Visual Studio 2005, libcurl 7.17.1
>            Reporter: Scott Cantor
>            Assignee: Alberto Massari
>             Fix For: 3.0.0
>
>
> 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)
>               {
>                       fd_set readSet;
>                       fd_set writeSet;
>                       fd_set exceptSet;
>                       int fdcnt=0;
>                       
>                       // Ask curl for the file descriptors to wait on
>                       FD_ZERO(&readSet);
>                       FD_ZERO(&writeSet);
>                       FD_ZERO(&exceptSet);
>                       (void) curl_multi_fdset(fMulti, &readSet, &writeSet, 
> &exceptSet, &fdcnt);
>                       
>                       // Wait on the file descriptors
>                       timeval tv;
>                       tv.tv_sec  = 2;
>                       tv.tv_usec = 0;
>                       (void) select(fdcnt, &readSet, &writeSet, &exceptSet, 
> &tv);
>               }
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to