Skip to content

Commit

Permalink
tcp: Fix allowed sending size calculation in can_send
Browse files Browse the repository at this point in the history
Hanlde the case when send window goes to zero or send window
decreases.

Message-Id: <c24a838863a4bb62a85c38310c8604a7293ee6e5.1526611968.git.asias@scylladb.com>
  • Loading branch information
asias authored and avikivity committed May 21, 2018
1 parent f20417e commit 6c61cd5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions net/tcp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,21 @@ private:
if (_snd.window_probe) {
return 1;
}
// Can not send more than advertised window allows
auto x = std::min(uint32_t(_snd.unacknowledged + _snd.window - _snd.next), _snd.unsent_len);

// Can not send if send window is zero
if (_snd.window == 0) {
return 0;
}

// Can not send if send window is less than unacknowledged data size
auto window_used = uint32_t(_snd.next - _snd.unacknowledged);
if (window_used > _snd.window) {
return 0;
}

// Can not send more than advertised window allows or unsent data size
auto x = std::min(_snd.window - window_used, _snd.unsent_len);

// Can not send more than congestion window allows
x = std::min(_snd.cwnd, x);
if (_snd.dupacks == 1 || _snd.dupacks == 2) {
Expand Down

0 comments on commit 6c61cd5

Please sign in to comment.