Adaptor modification - WOResponse streaming failure detection
Ben Scarola <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
Greetings,
Can someone validate my findings on this? The stock WO Apache adaptor
does not detect a broken pipe on the client side while streaming a
response. This means that the WOResponse will always read its entire
source InputStream and in turn dump all the content to the adaptor,
even if the pipe from Apache to the client is broken.
I've traced this behavior to a loop inside SendResponse() in
mod_WebObjects.c (line 465) and added the lines below (indicated with
---->). By inspecting Apache's "conn_rec" you can detect an aborted
connection and break out of the loop. This cause the WOResponse to
immediately stop reading data from its InputStream, and also cause a
broken pipe in the WOWorkerThread.
Now when WOResponse calls InputStream.close(), read() will return >= 0
if the InputStream was not fully processed, allowing the application to
detect a failed transmission. Does anyone see adverse side effects of
this modification? If a client disconnects from Apache is there any
chance that the pipe can be re-established?? Is there a reason for WO
to keep dumping data on the adaptor?
if ( (!r->header_only) && (resp->content_valid) ) {
while (resp->content_read < resp->content_length)
{
ap_soft_timeout("sending WebObjects response", r);
ap_rwrite(resp->content, resp->content_valid, r);
ap_kill_timeout(r);
----> if (r->connection->aborted) {
----> break;
----> }
resp_getResponseContent(resp, 1);
}
ap_soft_timeout("sending WebObjects response", r);
ap_rwrite(resp->content, resp->content_valid, r);
ap_kill_timeout(r);
}
thanks,
Ben Scarola