aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-07-24 04:13:53 (EDT)
committerThomas Becker2013-07-24 04:16:20 (EDT)
commit0049aa4322e9002b95cf3db0ed301a55204f7a29 (patch)
tree41a3543f92f8260513bc6e8eb08a24a8cea30646
parente4a720322544260a03c3a5a50a5d728785cec8ac (diff)
downloadorg.eclipse.jetty.project-0049aa4322e9002b95cf3db0ed301a55204f7a29.zip
org.eclipse.jetty.project-0049aa4322e9002b95cf3db0ed301a55204f7a29.tar.gz
org.eclipse.jetty.project-0049aa4322e9002b95cf3db0ed301a55204f7a29.tar.bz2
412418 HttpTransportOverSPDY fix race condition while sending push streams that could cause push data not to be sent. Fixes intermittent test issues in ReferrerPushStrategyTest
-rw-r--r--jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java b/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java
index 3ecc8b6..0c352e8 100644
--- a/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java
+++ b/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/http/HttpTransportOverSPDY.java
@@ -293,15 +293,27 @@ public class HttpTransportOverSPDY implements HttpTransport
private void sendNextResourceData()
{
- PushResource resource;
- if(active.compareAndSet(false, true))
+ LOG.debug("{} sendNextResourceData active: {}", hashCode(), active.get());
+ if (active.compareAndSet(false, true))
{
- resource = queue.poll();
- if (resource == null)
+ PushResource resource = queue.poll();
+ if (resource != null)
+ {
+ LOG.debug("Opening new push channel for: {}", resource);
+ HttpChannelOverSPDY pushChannel = newHttpChannelOverSPDY(resource.getPushStream(), resource.getPushRequestHeaders());
+ pushChannel.requestStart(resource.getPushRequestHeaders(), true);
return;
- LOG.debug("Opening new push channel for: {}", resource);
- HttpChannelOverSPDY pushChannel = newHttpChannelOverSPDY(resource.getPushStream(), resource.getPushRequestHeaders());
- pushChannel.requestStart(resource.getPushRequestHeaders(), true);
+ }
+
+ if (active.compareAndSet(true, false))
+ {
+ if (queue.peek() != null)
+ sendNextResourceData();
+ }
+ else
+ {
+ throw new IllegalStateException("active must not be false here! Concurrency bug!");
+ }
}
}
@@ -335,14 +347,15 @@ public class HttpTransportOverSPDY implements HttpTransport
public void failed(Throwable x)
{
LOG.debug("Creating push stream failed.", x);
+ sendNextResourceData();
}
});
}
private void complete()
{
- if(!active.compareAndSet(true, false))
- LOG.warn("complete() called and active==false? That smells like a concurrency bug!", new IllegalStateException());
+ if (!active.compareAndSet(true, false))
+ throw new IllegalStateException();
sendNextResourceData();
}