You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ics.uci.edu> on 1998/09/04 09:22:29 UTC

Re: client connection questions

>If ap_rwrite/ap_bwrite returns -1, does that *always* mean the connection
>is broken?  

It means a fatal error occurred on the write and the buffer is now in an
unknown state, so it is a pretty good bet that the connection is no
longer useful.  Note that EAGAIN (EWOULDBLOCK) and EINTR are the only
non-fatal errors.

>r->connection->aborted is only set if a soft_timeout happens, why not with
>hard_timeout too?

Because a hard_timeout results in a longjump completely out of the
request handling process.

>What is the "right" test to find out if the connection has been broken? 

Check for an error from the ap_rwrite/ap_bwrite calls.

>Here are two checks that seem right by eyeballing the source code, but
>leave eyes sore.
>
>if(r->connection->client->flags & B_EOUT) {
>    ... connection was broken ...

Actually, that is an internal flag that says the buffer is out-of-whack
and there is no point in trying to send any more data.  I wouldn't use
it outside the core.

>if(r->connection->client->fd < 0) {
>     ... connection was broken ...

That means the file descriptor has been closed.

I suppose what we should have is an ap_is_connection_dead(r) macro,
but just checking the return values is simpler.

....Roy