403370 move frameBytes.fail() call in StandardSession.flush() outside the synchronized block to avoid deadlock

This commit is contained in:
Thomas Becker 2013-03-15 15:48:50 +01:00
parent d0f3db0f34
commit e1a31f468e
1 changed files with 16 additions and 8 deletions

View File

@ -963,6 +963,7 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable
{ {
FrameBytes frameBytes = null; FrameBytes frameBytes = null;
ByteBuffer buffer = null; ByteBuffer buffer = null;
boolean failFrameBytes = false;
synchronized (queue) synchronized (queue)
{ {
if (flushing || queue.isEmpty()) if (flushing || queue.isEmpty())
@ -982,11 +983,7 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable
{ {
queue.remove(i); queue.remove(i);
if (stream != null && stream.isReset() && !(frameBytes instanceof ControlFrameBytes)) if (stream != null && stream.isReset() && !(frameBytes instanceof ControlFrameBytes))
{ failFrameBytes = true;
frameBytes.fail(new StreamException(stream.getId(), StreamStatus.INVALID_STREAM,
"Stream: " + stream + " is reset!"));
return;
}
break; break;
} }
@ -1001,10 +998,21 @@ public class StandardSession implements ISession, Parser.Listener, Dumpable
if (buffer == null) if (buffer == null)
return; return;
flushing = true; if (!failFrameBytes)
LOG.debug("Flushing {}, {} frame(s) in queue", frameBytes, queue.size()); {
flushing = true;
LOG.debug("Flushing {}, {} frame(s) in queue", frameBytes, queue.size());
}
}
if (failFrameBytes)
{
frameBytes.fail(new StreamException(frameBytes.getStream().getId(), StreamStatus.INVALID_STREAM,
"Stream: " + frameBytes.getStream() + " is reset!"));
}
else
{
write(buffer, frameBytes);
} }
write(buffer, frameBytes);
} }
private void append(FrameBytes frameBytes) private void append(FrameBytes frameBytes)