Re: [exim] Lost connection during delay

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Philip Hazel
Dátum:  
Címzett: exim-users
CC: Tony Finch
Tárgy: Re: [exim] Lost connection during delay
On Fri, 6 May 2005, Tony Finch wrote:

> On Fri, 6 May 2005, Nigel Metheringham wrote:
> >
> > If you use a select on the appropriate file handle in the exceptions set
> > then you should notice a close.
>
> That might be true on some implementations, but the BSD documentation says
> "The only exceptional condition detectable is out-of-band data received on
> a socket." However poll(2) is slightly more flexible in this area, and its
> POLLHUP flag does what we want.


Experiment, sadly, disagrees with you. I cannot get poll() to notice the
closure of a remote connection (running a 2.6.11-gentoo-r6 kernel). It
does not return the POLLHUP flag. What it does return is the POLLIN
flag, but that of course could mean that there is genuine input waiting.
The client end of the connection sits in CLOSE_WAIT state until the
timeout finishes[*]. This is true even if I split the timeout wait into
1-second mini-waits, so that it goes in and out of poll().

In any case, googling around poll() suggests that there are
interoperability problems.

I do not know how to test for "this socket has gone away", or even "if I
try to read from this socket, will it give me end-of-file?" without
trying to read from it. If I could, "delay" could be implemented in
1-second waits with a test in between each one, which would be better
than it is now.

Philip

--------------
[*] What happens then, of course, is that Exim tries to read or write to
the socket, and it notices the closure.

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.