cURL / Mailing Lists / curl-library / Single Mail


Re: Select returns -1 on all the multi examples in win32

From: Ray Satiro <>
Date: Thu, 20 Nov 2014 02:15:36 -0500

On 11/19/2014 7:45 AM, Daniel Stenberg wrote:
> On Mon, 17 Nov 2014, Ray Satiro wrote:
>> The multi examples other than multi-single don't follow the
>> documented cleanup order [1].
> It would of course be nice to get them to use the proper order as
> well. The order is more a SHOULD than MUST though and libcurl really
> should handle basically whatever order the app uses.

Ok. I'll change it in the ones I've touched so far.

>> assuming it is acceptable to continue looping after select error
> But is it? I think that's the question and I really can't give a good
> answer to it. If it fails on select() once, why would calling
> curl_multi_fdset again give anything different and given the same
> input surely a second invoke of select() will fail the same way again?

I don't know. Is it ever possible that curl_multi_fdset returns a valid
fd and in the window of time it takes before select is called something
invalidates the fd or an error occurs and then EBADF from select? Then
if curl_multi_perform and curl_multi_fdset again the bad fd is purged
and select works?

>> why not call curl_multi_perform() again to update the number of
>> running handles as is done in the case of select() success. Then the
>> loop will break if there are no running handles (!still_running) or
>> continue if there are.
> I think because if select() continues to return -1, it'll effectively
> become a busyloop eating 100% CPU.

Assuming it continues to return -1. This goes to what I said above, if
there is anything happening behind the scenes and if after select fails
curl_multi_perform and curl_multi_fdset are going to get updated

>> But if select() error should be considered hard then why not set
>> still_running = 0 in all multi examples?
> Leaning back and forth on this matter, I think I now favor treating it
> as a hard error. I can't think of any legitimate reason why it would
> be allowed to return -1 and have things continue.
> Can you?

Other than EINTR and the possible case I mentioned above, no. If those
aren't issues how about I make them all this:
/* Handle EINTR here, if you need to. */
fprintf("select() failed, errno %d.\n", errno);
still_running = 0;

List admin:
Received on 2014-11-20