Fixed potential race condition identified in #203

This commit is contained in:
Jeroen van Erp
2016-03-18 13:11:59 +01:00
parent 4f152749ce
commit 3c230a0fc4

View File

@@ -130,7 +130,12 @@ public final class ChannelInputStream
buf.putRawBytes(data, offset, len); buf.putRawBytes(data, offset, len);
buf.notifyAll(); buf.notifyAll();
} }
win.consume(len); // Potential fix for #203 (window consumed below 0).
// This seems to be a race condition if we receive more data, while we're already sending a SSH_MSG_CHANNEL_WINDOW_ADJUST
// And the window has not expanded yet.
synchronized (win) {
win.consume(len);
}
if (chan.getAutoExpand()) if (chan.getAutoExpand())
checkWindow(); checkWindow();
} }
@@ -153,4 +158,4 @@ public final class ChannelInputStream
return "< ChannelInputStream for Channel #" + chan.getID() + " >"; return "< ChannelInputStream for Channel #" + chan.getID() + " >";
} }
} }