375509 - Stalled stream stalls other streams or session control frames.

Additional improvements for thread visibility, and clarified code comment.
This commit is contained in:
Simone Bordet 2012-03-29 12:50:01 +02:00
parent ec5f424c8c
commit 50bc8fa400
1 changed files with 10 additions and 9 deletions

View File

@ -1005,8 +1005,8 @@ public class StandardSession implements ISession, Parser.Listener, Handler<Stand
{
private final IStream stream;
private final DataInfo dataInfo;
private int length;
private ByteBuffer buffer;
private int size;
private volatile ByteBuffer buffer;
private DataFrameBytes(Handler<C> handler, C context, IStream stream, DataInfo dataInfo)
{
@ -1024,11 +1024,11 @@ public class StandardSession implements ISession, Parser.Listener, Handler<Stand
if (windowSize <= 0)
return null;
length = dataInfo.length();
if (length > windowSize)
length = windowSize;
size = dataInfo.available();
if (size > windowSize)
size = windowSize;
buffer = generator.data(stream.getId(), length, dataInfo);
buffer = generator.data(stream.getId(), size, dataInfo);
return buffer;
}
catch (Throwable x)
@ -1041,13 +1041,14 @@ public class StandardSession implements ISession, Parser.Listener, Handler<Stand
@Override
public void complete()
{
stream.updateWindowSize(-length);
bufferPool.release(buffer);
stream.updateWindowSize(-size);
if (dataInfo.available() > 0)
{
// If we could not write a full data frame, then we need first
// to finish it, and then process the others (to avoid data garbling)
// We have written a frame out of this DataInfo, but there is more to write.
// We need to keep the correct ordering of frames, to avoid that another
// DataInfo for the same stream is written before this one is finished.
enqueueFirst(this);
}
else