diff options
author | Greg Wilkins | 2015-03-25 06:26:18 +0000 |
---|---|---|
committer | Greg Wilkins | 2015-03-26 01:18:06 +0000 |
commit | 5d14d0ca7a90639a2f0ee305b65fc15d13793b3c (patch) | |
tree | c39c71828ef2651836fd7a30bc3e6aaa571d9f7c | |
parent | ea8a0f0e9affc53098031aa23547a1515d98d038 (diff) | |
download | org.eclipse.jetty.project-5d14d0ca7a90639a2f0ee305b65fc15d13793b3c.tar.gz org.eclipse.jetty.project-5d14d0ca7a90639a2f0ee305b65fc15d13793b3c.tar.xz org.eclipse.jetty.project-5d14d0ca7a90639a2f0ee305b65fc15d13793b3c.zip |
removed extra HttpInput synchronization
-rw-r--r-- | jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java | 24 | ||||
-rw-r--r-- | jetty-util/src/main/java/org/eclipse/jetty/util/ArrayQueue.java | 6 |
2 files changed, 15 insertions, 15 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java index 09d254cb55..44ed04fb5e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java @@ -28,7 +28,6 @@ import javax.servlet.ServletInputStream; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.RuntimeIOException; -import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.ArrayQueue; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; @@ -115,7 +114,6 @@ public class HttpInput extends ServletInputStream implements Runnable private void wake() { - // TODO review if this is correct _channelState.getHttpChannel().getConnector().getExecutor().execute(_channelState.getHttpChannel()); } @@ -349,7 +347,7 @@ public class HttpInput extends ServletInputStream implements Runnable throw (IOException)new InterruptedIOException().initCause(e); } } - + /** * Adds some content to this input stream. * @@ -360,18 +358,14 @@ public class HttpInput extends ServletInputStream implements Runnable boolean woken=false; synchronized (_inputQ) { - boolean wasEmpty = _inputQ.isEmpty(); - _inputQ.add(item); + _inputQ.addUnsafe(item); if (LOG.isDebugEnabled()) LOG.debug("{} addContent {}", this, item); - if (wasEmpty) // TODO do we need this guard? - { - if (_listener==null) - _inputQ.notify(); - else - woken=_channelState.onReadPossible(); - } + if (_listener==null) + _inputQ.notify(); + else + woken=_channelState.onReadPossible(); } return woken; @@ -381,7 +375,7 @@ public class HttpInput extends ServletInputStream implements Runnable { synchronized (_inputQ) { - return !_inputQ.isEmpty(); + return _inputQ.sizeUnsafe()>0; } } @@ -580,7 +574,7 @@ public class HttpInput extends ServletInputStream implements Runnable { if (error!=null) { - _channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE); // TODO ??? + _channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE); listener.onError(error); } else if (aeof) @@ -596,7 +590,7 @@ public class HttpInput extends ServletInputStream implements Runnable { if (aeof || error==null) { - _channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE); // TODO ??? + _channelState.getHttpChannel().getResponse().getHttpFields().add(HttpConnection.CONNECTION_CLOSE); listener.onError(e); } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayQueue.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayQueue.java index 0c3b545261..a02c804ace 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayQueue.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayQueue.java @@ -255,6 +255,12 @@ public class ArrayQueue<E> extends AbstractList<E> implements Queue<E> } /* ------------------------------------------------------------ */ + public int sizeUnsafe() + { + return _size; + } + + /* ------------------------------------------------------------ */ @Override public E get(int index) { |