Skip to content

Commit

Permalink
Fixed potential race condition identified in #203
Browse files Browse the repository at this point in the history
  • Loading branch information
hierynomus committed Mar 18, 2016
1 parent 4f15274 commit 3c230a0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ public void receive(byte[] data, int offset, int len)
buf.putRawBytes(data, offset, len);
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())
checkWindow();
}
Expand All @@ -153,4 +158,4 @@ public String toString() {
return "< ChannelInputStream for Channel #" + chan.getID() + " >";
}

}
}

0 comments on commit 3c230a0

Please sign in to comment.