[Xcb] [PATCH] _xcb_conn_wait(): Do better at detecting closed sockets
Uli Schlachter
psychon at znc.in
Mon Oct 17 12:34:42 UTC 2016
On 13.10.2016 21:53, Adam Jackson wrote:
> On Thu, 2016-10-13 at 20:20 +0200, Uli Schlachter wrote:
>> On 13.10.2016 17:02, Adam Jackson wrote:
>> How about fixing this properly in Xlib instead? If it wants to check
>> if the error was due to "the other end closed the connection", it can
>> do something like this:
>
> Fair enough. Do note that the existing code already does consider this
> case to be an error, due to the stanza above the bit I added:
>
> ret = poll(&fd, 1, -1);
> /* If poll() returns an event we didn't expect, such as POLLNVAL, treat
> * it as if it failed. */
> if(ret >= 0 && (fd.revents & ~fd.events))
> {
> ret = -1;
> break;
> }
>
> Since we're not presently adding POLLHUP to fd.events...
Oh, thanks for reminding me. "man poll" tells me that setting "POLLHUP"
in "events" has no effect:
[The field "events"] may be specified as zero, in
which case the only events that can be returned in
revents are POLLHUP, POLLERR, and POLLNVAL (see below).
The field revents is an output parameter, filled by the
kernel with the events that actually occurred. The bits
returned in revents can include any of those specified
in events, or one of the values POLLERR, POLLHUP, or POLLNVAL.
(These three bits are meaningless in the events field, and
will be set in the revents field whenever the corresponding
condition is true.)
Uli
--
“Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold. Cold.” – Anna
More information about the Xcb
mailing list