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 Parser _parser;
protected final HttpFields _requestFields; protected final HttpFields _requestFields;
protected final Request _request; protected final Request _request;
protected ServletInputStream _in; protected volatile ServletInputStream _in;
protected final Generator _generator; protected final Generator _generator;
protected final HttpFields _responseFields; protected final HttpFields _responseFields;
protected final Response _response; protected final Response _response;
protected Output _out; protected volatile Output _out;
protected OutputWriter _writer; protected volatile OutputWriter _writer;
protected PrintWriter _printWriter; protected volatile PrintWriter _printWriter;
int _include; int _include;

View File

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