410337 HttpOutput calls now HttpChannel.close() instead of closing the endPoint directly. That way the different implementations of HttpChannel can decide if the endPoint should be shutdown or not.

This commit is contained in:
Thomas Becker 2013-06-11 16:16:57 +02:00
parent c5bdc019a2
commit beba00c5e0
3 changed files with 17 additions and 4 deletions

View File

@ -672,7 +672,6 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
* @param content the content buffer to write
* @param complete whether the content is complete for the response
* @param callback Callback when complete or failed
* @throws IOException if the write fails
*/
protected void write(ByteBuffer content, boolean complete, Callback callback)
{
@ -698,6 +697,14 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
return getEndPoint() instanceof ChannelEndPoint;
}
/**
* If a write or similar to this channel fails this method should be called. The standard implementation
* of {@link #failed()} is a noop. But the different implementations of HttpChannel might want to take actions.
*/
public void failed()
{
}
private class CommitCallback implements Callback
{
private final Callback _callback;

View File

@ -578,6 +578,12 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
_generator.setPersistent(false);
super.handleException(x);
}
@Override
public void failed()
{
getEndPoint().shutdownOutput();
}
}
private class CommitCallback extends IteratingCallback

View File

@ -99,7 +99,7 @@ public class HttpOutput extends ServletOutputStream
}
catch(IOException e)
{
_channel.getEndPoint().shutdownOutput();
_channel.failed();
LOG.ignore(e);
}
releaseBuffer();
@ -120,7 +120,7 @@ public class HttpOutput extends ServletOutputStream
}
catch(IOException e)
{
_channel.getEndPoint().shutdownOutput();
_channel.failed();
LOG.ignore(e);
}
}
@ -168,7 +168,7 @@ public class HttpOutput extends ServletOutputStream
public void write(byte[] b, int off, int len) throws IOException
{
if (isClosed())
throw new EOFException("Closed");
throw new EOFException("Closed:" + System.identityHashCode(this));
_written+=len;
boolean complete=_channel.getResponse().isAllContentWritten(_written);