Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-02-13 00:45:56 +0000
committerGreg Wilkins2015-02-13 00:45:56 +0000
commit0f7ee8d607d9f74debe0698237e46b20375680a9 (patch)
tree4806e5bbccd0fb1fb43a6357608e77d00c82ef46 /jetty-websocket
parent1f90d62d3fb83de1ff74ae7a7d1ca888eee07617 (diff)
parent2b2a70a93a50fd20f17f38be82b8e15d1365dccd (diff)
downloadorg.eclipse.jetty.project-0f7ee8d607d9f74debe0698237e46b20375680a9.tar.gz
org.eclipse.jetty.project-0f7ee8d607d9f74debe0698237e46b20375680a9.tar.xz
org.eclipse.jetty.project-0f7ee8d607d9f74debe0698237e46b20375680a9.zip
Merge remote-tracking branch 'origin/jetty-9.2.x'
Conflicts: jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java jetty-http/src/main/java/org/eclipse/jetty/http/HttpVersion.java jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
Diffstat (limited to 'jetty-websocket')
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java1
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java27
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java3
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerConnection.java11
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java2
5 files changed, 35 insertions, 9 deletions
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
index 8ba9cbc056..530c010b92 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
@@ -265,6 +265,7 @@ public class UpgradeConnection extends AbstractConnection
connectPromise.getClient().addManaged(session);
// Now swap out the connection
+ // TODO use endp.upgrade ???
endp.setConnection(connection);
connection.onOpen();
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
index 1e8ef2f883..47e1cc6f08 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
@@ -215,6 +215,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
private WebSocketSession session;
private List<ExtensionConfig> extensions;
private boolean isFilling;
+ private ByteBuffer buffer;
private ReadMode readMode = ReadMode.PARSE;
private IOState ioState;
private Stats stats = new Stats();
@@ -250,7 +251,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
/**
* Close the connection.
- * <p>
+ * <p> fillInterested();
+
* This can result in a close handshake over the network, or a simple local abnormal close
*
* @param statusCode
@@ -422,9 +424,14 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
switch (state)
{
case OPEN:
- if (LOG.isDebugEnabled())
- LOG.debug("fillInterested");
- fillInterested();
+ if (BufferUtil.isEmpty(buffer))
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("fillInterested");
+ fillInterested();
+ }
+ else
+ onFillable();
break;
case CLOSED:
if (ioState.wasAbnormalClose())
@@ -458,7 +465,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
if (LOG.isDebugEnabled())
LOG.debug("{} onFillable()",policy.getBehavior());
stats.countOnFillableEvents.incrementAndGet();
- ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
+ if (buffer==null)
+ buffer = bufferPool.acquire(getInputBufferSize(),true);
try
{
isFilling = true;
@@ -466,7 +474,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
if(readMode == ReadMode.PARSE)
{
readMode = readParse(buffer);
- } else
+ }
+ else
{
readMode = readDiscard(buffer);
}
@@ -474,6 +483,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
finally
{
bufferPool.release(buffer);
+ buffer=null;
}
if ((readMode != ReadMode.EOF) && (suspendToken.get() == false))
@@ -496,6 +506,11 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
super.onFillInterestedFailed(cause);
}
+ protected void prefill(ByteBuffer prefilled)
+ {
+ buffer=prefilled;
+ }
+
@Override
public void onOpen()
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java
index 09e6c27feb..6a8851d467 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java
@@ -293,7 +293,8 @@ public class IOState
{
notifyStateListeners(event);
- if(abnormalEvent != null) {
+ if(abnormalEvent != null)
+ {
notifyStateListeners(abnormalEvent);
}
}
diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerConnection.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerConnection.java
index f68805700f..25731f5dfd 100644
--- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerConnection.java
+++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerConnection.java
@@ -19,17 +19,20 @@
package org.eclipse.jetty.websocket.server;
import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
-public class WebSocketServerConnection extends AbstractWebSocketConnection
+public class WebSocketServerConnection extends AbstractWebSocketConnection implements Connection.UpgradeTo
{
private final AtomicBoolean opened = new AtomicBoolean(false);
@@ -55,6 +58,12 @@ public class WebSocketServerConnection extends AbstractWebSocketConnection
}
@Override
+ public void onUpgradeTo(ByteBuffer prefilled)
+ {
+ prefill(prefilled);
+ }
+
+ @Override
public void onOpen()
{
boolean beenOpened = opened.getAndSet(true);
diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java
index 354a617e20..af13f03a1e 100644
--- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java
+++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java
@@ -85,7 +85,7 @@ public class TooFastClientTest
Generator generator = new Generator(WebSocketPolicy.newClientPolicy(),
new LeakTrackingBufferPool("Generator",new MappedByteBufferPool()));
String msg1 = "Echo 1";
- String msg2 = "This is also an echo ... cho ... ho ... o";
+ String msg2 = "This is also an echooooo!";
generator.generateWholeFrame(new TextFrame().setPayload(msg1),initialPacket);
generator.generateWholeFrame(new TextFrame().setPayload(msg2),initialPacket);

Back to the top