cURL / Mailing Lists / curl-library / Single Mail

curl-library

poll() POLLERR / POLLHUP without POLLIN / POLLOUT

From: Yang Tse <yangsita_at_gmail.com>
Date: Fri, 11 Sep 2009 14:34:06 +0200

28 Jul 2009 Joshua Kwan http://curl.haxx.se/mail/lib-2009-07/0292.html wrote:

> We have a Glib-style event loop implementation into which the
> multi API is hooked. Presumably due to the network disconnection,
> polling on the FD responsible for name resolution is in a
> 'POLLERR' state (indicating some error with the socket.) We call
> curl_multi_socket_action to indicate this error to libcurl.
> However, libcurl does not appear to ask us to remove the FD from
> the poll loop.

IOW poll() might set POLLHUP in revents without setting POLLIN, and
might set POLLERR without setting POLLIN and POLLOUT.

Joshua, which I/O library and version is behaving in this way? Or
which OS and version is doing this?

29 Jul 2009 Daniel Stenberg
http://curl.haxx.se/mail/lib-2009-07/0293.html wrote:

> I figure we would basically need an "error" action that could
> let libcurl treat it as bad and act on it, but as I remember
> things we don't atm.

10 Sep 2009 Joshua Kwan http://curl.haxx.se/mail/lib-2009-09/0138.html wrote:

> This simple patch makes it so that cURL properly communicates
> the POLLERR state to c-ares (as well as POLLHUP.)

No the patch does not tell c-ares that the file descriptor has an
POLLERR or POLLHUP condition, it simply tells that c-ares should
process the file descriptor as if it had a POLLIN revent whenever it
has a POLLERR or POLLHUP condition, and process the file descriptor as
if it had a POLLOUT revent whenever it has a POLLERR.

In this way , c-ares will attempt to read or write on the fd and fail.
But this failure might very well trigger additional lookups and
finally make c-ares mark all configured DNS servers as unavailable.
Which isn't necessarily bad.

My concern is that this patch addresses the lack of POLLIN and POLLOUT
when POLLERR or POLLHUP is reported by poll in a very specific point
of libcurl awaiting c-ares to resolve. But if the condition arises at
other moments of the connection/transfer I fear that you will be
facing the same problem of not detecting POLLERR or POLLHUP when poll
does not set POLLIN or POLLOUT, but in this case libcurl should simply
timeout somewhere.

-- 
-=[Yang]=-
Received on 2009-09-11