cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_fdset() and select()

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 9 Sep 2006 22:22:42 +0200 (CEST)

On Sat, 9 Sep 2006, Gisle Vanem wrote:

> On the first return from curl_multi_fdset(), max_fd would be -1. This
> doesn't go well with Winsock; it doesn't like "select (0, ..., &interval)"
> which is equal to a sleep(1).
>
> I was thinking of changing the if-statement into:
>
> if (max_fd > -1 && select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
> fprintf(stderr, "bad select??\n");
> return 95;
> }
>
> Does this hurt on other platforms than Win32?

No, it would work on all platforms and yes it makes sense to not blindly
assume that curl_multi_fdset() returns something.

> Or should we code our own select() (in first.c) that handles the max_fd ==
> -1 case?

Yes, perhaps that's a comfortable way to easily have this approach for all
test case codes.

But note that skipping the select() completely will cause a busy-loop until
there's traffic, so perhaps it makes sense to do at least a slight delay for
the case where curl_multi_fdset() returns -1?

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-09-09