cURL / Mailing Lists / curl-library / Single Mail

curl-library

Patch: partial fix for bug #948950

From: David Phillips <electrum_at_gmail.com>
Date: Tue, 16 Nov 2004 18:58:54 -0600

This patch addresses bug #948950: excessive amount of file descriptors
cause crash in libcurl. It fixes the bug for most uses of the
library, but does attempt to correct the API issue. It has been
tested on SUSE Linux 9.0 and passes all test cases.

The bug is mainly fixed by creating a new internal function,
Curl_select(). It lives in select.c and select.h. The function is a
replacement for simple calls to select with a single read and/or write
file descriptor event. Errors and timeouts are reported, along with
read, write or error events.

Curl_select() uses poll() if available, otherwise it uses select().
If select() is used, then curlassert() is used to check the validity
of file descriptors passed to FD_SET().

I haven't attempted to fix everything as I would like to get some
feedback first. Things which aren't fixed:

- telnet.c: This requires a read event on two descriptors. This is
relatively easy to fix with another wrapper function that uses a
poll() style interface.

- hostares.c: This requires multiple events. More importantly, it
requires changes to the ares library.

- curl_multi_fdset() and related issues: In order to make the code
safe and usable with more than FD_SETSIZE file descriptors, I removed
the FD_SET() calls in the normal-case code. Did this break break
curl_multi_fdset()? A new API function should be introduced that uses
a safer method of returning file descriptors. For the current method,
checks should be put in place anytime FD_SET() is called.

Please give me feedback on this patch. It currently serves our needs,
but I would like to get this fix into the main distribution and
hopefully into the next release.

-- 
David Phillips <david_at_acz.org>
http://david.acz.org/

Received on 2004-11-17