Fixed update of stream closed status in case of data frames.

It was possible that a client sent a data frame with close=true, but the half close of the
stream was delayed until after all the data bytes were sent.
The server received the data bytes and sent a reply with close=true that could have been
processed before the stream was actually half closed by the data frame delayed update,
and this generated a race condition.
Now the close status is updated before sending the data (like all other frames), but the
stream is removed only when data has been fully sent.
This commit is contained in:
Simone Bordet 2012-01-30 21:14:03 +01:00
parent 4cbca7a664
commit b8a5d9062f
2 changed files with 1 additions and 4 deletions

View File

@ -718,7 +718,6 @@ public class StandardSession implements ISession, Parser.Listener, ISession.Cont
}
else
{
stream.updateCloseState(data.isClose());
if (stream.isClosed())
removeStream(stream);
}

View File

@ -247,9 +247,7 @@ public class StandardStream implements IStream
@Override
public void data(DataInfo dataInfo)
{
// We do not update the close state here, because the dataInfo may
// generate several frames and in the middle we may receive window
// updates, so we need the stream to update the window size
updateCloseState(dataInfo.isClose());
session.data(this, dataInfo);
}