[Zope-dev] Zope closes connection if the client closes the write-end of connection

Izak Burger izak at upfrontsystems.co.za
Fri Oct 16 12:05:55 EDT 2009


Tres Seaver wrote:
> You might also look at "fixing" varnish:  I don't know of any valid
> reason for it to be using the "half-open" connection model to test that
> an HTTP-based backend is "up" -- certainly no browser in the world does
> that;  instead, modern browsers nearly always try to keep the connection
> open for subsequent requests.

I have already "fixed" varnish, I commented out the shutdown() call. It 
now works as expected.

I just had a discussion about this with a colleague and it appears 
unclear exactly where to blame this.

When a client half-closes its connection while the server was calling 
recv(), it makes absolute sense that recv() SHOULD return an empty 
buffer. There is nothing to return, and there won't ever be, the 
connection has been closed. Python is therefore not to blame, even if it 
doesn't specifically check all the possible revents returned by poll().

When asyncore receives an empty result from recv(), it does correctly 
assume that the connection was shut down. It doesn't seem wrong for 
asyncore to let the upper layers know about this. It would seem that 
asyncore is not to blame either.

When asyncore calls the close() method inside zope, it ends up shuting 
down the whole thing. Though I could argue that zope shouldn't be doing 
this, the idea of a half-open connection doesn't work all that well in 
python/asyncore anyway, so given the framework within which zope 
operates, zope isn't to blame either.

Given that no browser (that I know of) does this half-closing thing, I 
would argue that varnish should at the very least offer a shutdown 
option for probing, so as to appear more like a browser.

In addition, HTTP 1.1 usually leaves the connection open unless you ask 
for it to be closed, so it almost seems more common not to shutdown the 
one end.

It seems then that the only way to "fix" this is to either put zope 
behind apache or something else that can handle half-closing, or to 
"fix" varnish.

regards,
Izak


More information about the Zope-Dev mailing list