412418 HttpTransportOverSPDY fix race condition while sending push streams that could cause push data not to be sent. Fixes intermittent test issues in ReferrerPushStrategyTest
This commit is contained in:
parent
eb126ebaee
commit
1ab5de8ecd
|
@ -294,15 +294,27 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
|
|
||||||
private void sendNextResourceData()
|
private void sendNextResourceData()
|
||||||
{
|
{
|
||||||
PushResource resource;
|
LOG.debug("{} sendNextResourceData active: {}", hashCode(), active.get());
|
||||||
if (active.compareAndSet(false, true))
|
if (active.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
resource = queue.poll();
|
PushResource resource = queue.poll();
|
||||||
if (resource == null)
|
if (resource != null)
|
||||||
return;
|
{
|
||||||
LOG.debug("Opening new push channel for: {}", resource);
|
LOG.debug("Opening new push channel for: {}", resource);
|
||||||
HttpChannelOverSPDY pushChannel = newHttpChannelOverSPDY(resource.getPushStream(), resource.getPushRequestHeaders());
|
HttpChannelOverSPDY pushChannel = newHttpChannelOverSPDY(resource.getPushStream(), resource.getPushRequestHeaders());
|
||||||
pushChannel.requestStart(resource.getPushRequestHeaders(), true);
|
pushChannel.requestStart(resource.getPushRequestHeaders(), true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active.compareAndSet(true, false))
|
||||||
|
{
|
||||||
|
if (queue.peek() != null)
|
||||||
|
sendNextResourceData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("active must not be false here! Concurrency bug!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,6 +348,7 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
public void failed(Throwable x)
|
public void failed(Throwable x)
|
||||||
{
|
{
|
||||||
LOG.debug("Creating push stream failed.", x);
|
LOG.debug("Creating push stream failed.", x);
|
||||||
|
sendNextResourceData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -343,7 +356,7 @@ public class HttpTransportOverSPDY implements HttpTransport
|
||||||
private void complete()
|
private void complete()
|
||||||
{
|
{
|
||||||
if (!active.compareAndSet(true, false))
|
if (!active.compareAndSet(true, false))
|
||||||
LOG.warn("complete() called and active==false? That smells like a concurrency bug!", new IllegalStateException());
|
throw new IllegalStateException();
|
||||||
sendNextResourceData();
|
sendNextResourceData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue