Synchronized the generation and enqueuing of control frames, in order to maintain a correct compression context.
This commit is contained in:
parent
980d728502
commit
50ead5c19c
|
@ -717,12 +717,20 @@ public class StandardSession implements ISession, Parser.Listener, Handler<Stand
|
||||||
{
|
{
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
updateLastStreamId(stream); // TODO: not sure this is right
|
updateLastStreamId(stream); // TODO: not sure this is right
|
||||||
|
|
||||||
|
// Synchronization is necessary, since we may have concurrent replies
|
||||||
|
// and those needs to be generated and enqueued atomically in order
|
||||||
|
// to maintain a correct compression context
|
||||||
|
synchronized (this)
|
||||||
|
{
|
||||||
ByteBuffer buffer = generator.control(frame);
|
ByteBuffer buffer = generator.control(frame);
|
||||||
logger.debug("Queuing {} on {}", frame, stream);
|
logger.debug("Queuing {} on {}", frame, stream);
|
||||||
ControlFrameBytes<C> frameBytes = new ControlFrameBytes<>(frame, buffer, handler, context);
|
ControlFrameBytes<C> frameBytes = new ControlFrameBytes<>(frame, buffer, handler, context);
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
frameBytes.task = scheduler.schedule(frameBytes, timeout, unit);
|
frameBytes.task = scheduler.schedule(frameBytes, timeout, unit);
|
||||||
enqueueLast(frameBytes);
|
enqueueLast(frameBytes);
|
||||||
|
}
|
||||||
|
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue