JETTY-1475 made output state fields volatile to provide memory barrier for non dispatched thread IO

This commit is contained in:
Greg Wilkins 2012-01-18 14:16:09 +11:00
parent 9ff8633554
commit 3e04cac272
2 changed files with 10 additions and 9 deletions

View File

@ -102,14 +102,14 @@ public abstract class AbstractHttpConnection extends AbstractConnection
protected final Parser _parser;
protected final HttpFields _requestFields;
protected final Request _request;
protected ServletInputStream _in;
protected volatile ServletInputStream _in;
protected final Generator _generator;
protected final HttpFields _responseFields;
protected final Response _response;
protected Output _out;
protected OutputWriter _writer;
protected PrintWriter _printWriter;
protected volatile Output _out;
protected volatile OutputWriter _writer;
protected volatile PrintWriter _printWriter;
int _include;
@ -122,7 +122,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
private boolean _expect102Processing = false;
private boolean _head = false;
private boolean _host = false;
private boolean _delayedHandling=false;
private boolean _delayedHandling=false;
/* ------------------------------------------------------------ */
public static AbstractHttpConnection getCurrentConnection()

View File

@ -81,7 +81,7 @@ public class Response implements HttpServletResponse
private String _characterEncoding;
private boolean _explicitEncoding;
private String _contentType;
private int _outputState;
private volatile int _outputState;
private PrintWriter _writer;
/* ------------------------------------------------------------ */
@ -108,8 +108,8 @@ public class Response implements HttpServletResponse
_characterEncoding=null;
_explicitEncoding=false;
_contentType=null;
_outputState=NONE;
_writer=null;
_outputState=NONE;
}
/* ------------------------------------------------------------ */
@ -646,8 +646,9 @@ public class Response implements HttpServletResponse
if (_outputState!=NONE && _outputState!=STREAM)
throw new IllegalStateException("WRITER");
ServletOutputStream out = _connection.getOutputStream();
_outputState=STREAM;
return _connection.getOutputStream();
return out;
}
/* ------------------------------------------------------------ */
@ -1065,8 +1066,8 @@ public class Response implements HttpServletResponse
{
resetBuffer();
_outputState=NONE;
_writer=null;
_outputState=NONE;
}
/* ------------------------------------------------------------ */