diff options
author | Noah Eisen <ncteisen@gmail.com> | 2018-08-14 09:18:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 09:18:08 -0700 |
commit | c175652de006a4bdb279cfaa0c43836e60ae8fbf (patch) | |
tree | 4139703f0f11e38f792681768abe3cc69800d047 | |
parent | 1973af745352efe7a3acd9377c35e85983941de6 (diff) | |
parent | 5e1cf109da7713592b894366cdb78413e28e44f3 (diff) |
Merge pull request #16344 from ncteisen/flow-control-fix
Fix Clamp for Window Update
-rw-r--r-- | src/core/ext/transport/chttp2/transport/flow_control.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core/ext/transport/chttp2/transport/flow_control.cc b/src/core/ext/transport/chttp2/transport/flow_control.cc index 5f3dd98461..53932bcb7f 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.cc +++ b/src/core/ext/transport/chttp2/transport/flow_control.cc @@ -40,6 +40,7 @@ namespace chttp2 { namespace { static constexpr const int kTracePadding = 30; +static constexpr const uint32_t kMaxWindowUpdateSize = (1u << 31) - 1; static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) { char* str; @@ -193,7 +194,7 @@ uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) { if ((writing_anyway || announced_window_ <= target_announced_window / 2) && announced_window_ != target_announced_window) { const uint32_t announce = static_cast<uint32_t> GPR_CLAMP( - target_announced_window - announced_window_, 0, UINT32_MAX); + target_announced_window - announced_window_, 0, kMaxWindowUpdateSize); announced_window_ += announce; return announce; } @@ -267,7 +268,7 @@ uint32_t StreamFlowControl::MaybeSendUpdate() { FlowControlTrace trace("s updt sent", tfc_, this); if (local_window_delta_ > announced_window_delta_) { uint32_t announce = static_cast<uint32_t> GPR_CLAMP( - local_window_delta_ - announced_window_delta_, 0, UINT32_MAX); + local_window_delta_ - announced_window_delta_, 0, kMaxWindowUpdateSize); UpdateAnnouncedWindowDelta(tfc_, announce); return announce; } |