Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-02-26 04:37:51 +0000
committerGreg Wilkins2015-02-26 04:37:51 +0000
commitaf70c4bd48969f7995c0e4ec9fa3ea83582d676f (patch)
tree704418e4d5bbba3e832047d4e8aa9b33ebf4708d
parent752973931ed19848114f399bdae2f2431e67180a (diff)
downloadorg.eclipse.jetty.project-af70c4bd48969f7995c0e4ec9fa3ea83582d676f.tar.gz
org.eclipse.jetty.project-af70c4bd48969f7995c0e4ec9fa3ea83582d676f.tar.xz
org.eclipse.jetty.project-af70c4bd48969f7995c0e4ec9fa3ea83582d676f.zip
protect event schedule race
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java16
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java10
-rw-r--r--tests/test-integration/src/test/java/org/eclipse/jetty/test/HttpInputIntegrationTest.java1
3 files changed, 12 insertions, 15 deletions
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java
index 99bc90870c..b7a7423164 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java
@@ -291,7 +291,7 @@ public class HttpChannelState
protected Action unhandle()
{
Action action;
- boolean schedule_timeout=false;
+ AsyncContextEvent schedule_event=null;
boolean read_interested=false;
if(DEBUG)
@@ -344,9 +344,9 @@ public class HttpChannelState
_state=State.ASYNC_IO;
action = Action.WRITE_CALLBACK;
}
- else
+ else
{
- schedule_timeout=true;
+ schedule_event=_event;
read_interested=_asyncReadUnready;
_state=State.ASYNC_WAIT;
action = Action.WAIT;
@@ -354,7 +354,7 @@ public class HttpChannelState
break;
case EXPIRING:
- schedule_timeout=true;
+ schedule_event=_event;
_state=State.ASYNC_WAIT;
action = Action.WAIT;
break;
@@ -372,8 +372,8 @@ public class HttpChannelState
}
}
- if (schedule_timeout)
- scheduleTimeout();
+ if (schedule_event!=null)
+ scheduleTimeout(schedule_event);
if (read_interested)
_channel.asyncReadFillInterested();
return action;
@@ -611,11 +611,11 @@ public class HttpChannelState
_channel.execute(_channel);
}
- protected void scheduleTimeout()
+ protected void scheduleTimeout(AsyncContextEvent event)
{
Scheduler scheduler = _channel.getScheduler();
if (scheduler!=null && _timeoutMs>0)
- _event.setTimeoutTask(scheduler.schedule(_event,_timeoutMs,TimeUnit.MILLISECONDS));
+ event.setTimeoutTask(scheduler.schedule(event,_timeoutMs,TimeUnit.MILLISECONDS));
}
protected void cancelTimeout()
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
index 874f094339..800cd09832 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
@@ -19,7 +19,6 @@
package org.eclipse.jetty.server;
import java.io.IOException;
-import java.lang.ref.Reference;
import java.nio.ByteBuffer;
import java.nio.channels.WritePendingException;
import java.util.concurrent.RejectedExecutionException;
@@ -70,7 +69,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
private final BlockingReadCallback _blockingReadCallback = new BlockingReadCallback();
private final AsyncReadCallback _asyncReadCallback = new AsyncReadCallback();
private final SendCallback _sendCallback = new SendCallback();
-
+
/**
* Get the current connection that this thread is dispatched to.
* Note that a thread may be processing a request asynchronously and
@@ -200,7 +199,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
{
if (_requestBuffer == null)
_requestBuffer = _bufferPool.acquire(getInputBufferSize(), REQUEST_BUFFER_DIRECT);
- return _requestBuffer;
+ return _requestBuffer;
}
public boolean isRequestBufferEmpty()
@@ -221,10 +220,10 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
{
// Fill the request buffer (if needed)
int filled = fillRequestBuffer();
-
+
// Parse the request buffer
boolean handle = parseRequestBuffer();
-
+
// Handle close parser
if (_parser.isClose())
{
@@ -258,7 +257,6 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
LOG.debug("{} onFillable exit {}", this, _channel.getState());
}
}
-
/* ------------------------------------------------------------ */
/** Fill and parse data looking for content
diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/HttpInputIntegrationTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/HttpInputIntegrationTest.java
index 2eaadcfda3..52f53d9c01 100644
--- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/HttpInputIntegrationTest.java
+++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/HttpInputIntegrationTest.java
@@ -126,7 +126,6 @@ public class HttpInputIntegrationTest
// HTTP/2 Connector
ServerConnector http2Connector =
new ServerConnector(__server,ssl,/*TODO alpn,h2,*/ h1);
- http2Connector.setPort(8443);
__server.addConnector(http2Connector);

Back to the top