Issue 128: Convert frame::Reason to struct (#142)
Alter frame::Reason to a struct with a single u32 member. Introduce Constants to the impl for existing Reasons. Change all usage in the library and its tests to adopt this change, using the new constants.
This commit is contained in:
committed by
Carl Lerche
parent
1c179f7bf2
commit
2aee78c7d7
@@ -103,11 +103,11 @@ impl FlowControl {
|
||||
let (val, overflow) = self.window_size.overflowing_add(sz as i32);
|
||||
|
||||
if overflow {
|
||||
return Err(Reason::FlowControlError);
|
||||
return Err(Reason::FLOW_CONTROL_ERROR);
|
||||
}
|
||||
|
||||
if val > MAX_WINDOW_SIZE as i32 {
|
||||
return Err(Reason::FlowControlError);
|
||||
return Err(Reason::FLOW_CONTROL_ERROR);
|
||||
}
|
||||
|
||||
trace!(
|
||||
@@ -126,7 +126,12 @@ impl FlowControl {
|
||||
/// This is called after receiving a SETTINGS frame with a lower
|
||||
/// INITIAL_WINDOW_SIZE value.
|
||||
pub fn dec_window(&mut self, sz: WindowSize) {
|
||||
trace!("dec_window; sz={}; window={}, available={}", sz, self.window_size, self.available);
|
||||
trace!(
|
||||
"dec_window; sz={}; window={}, available={}",
|
||||
sz,
|
||||
self.window_size,
|
||||
self.available
|
||||
);
|
||||
// This should not be able to overflow `window_size` from the bottom.
|
||||
self.window_size -= sz as i32;
|
||||
self.available = self.available.saturating_sub(sz);
|
||||
|
||||
Reference in New Issue
Block a user