Fix bug in prioritization (#63)

The stream buffered data counter was never decremented.
This commit is contained in:
Carl Lerche
2017-09-07 14:12:21 -07:00
committed by GitHub
parent 09744f38ef
commit 38bbf30b2f
9 changed files with 186 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ pub use self::window_update::WindowUpdate;
// Re-export some constants
pub use self::settings::{
DEFAULT_SETTINGS_HEADER_TABLE_SIZE,
DEFAULT_INITIAL_WINDOW_SIZE,
DEFAULT_MAX_FRAME_SIZE,
MAX_INITIAL_WINDOW_SIZE,
MAX_MAX_FRAME_SIZE,

View File

@@ -12,6 +12,7 @@ pub struct Ping {
}
impl Ping {
#[cfg(feature = "unstable")]
pub fn new() -> Ping {
Ping {
ack: false,

View File

@@ -36,6 +36,9 @@ const ALL: u8 = ACK;
/// The default value of SETTINGS_HEADER_TABLE_SIZE
pub const DEFAULT_SETTINGS_HEADER_TABLE_SIZE: usize = 4_096;
/// The default value of SETTINGS_INITIAL_WINDOW_SIZE
pub const DEFAULT_INITIAL_WINDOW_SIZE: u32 = 65_535;
/// The default value of MAX_FRAME_SIZE
pub const DEFAULT_MAX_FRAME_SIZE: FrameSize = 16_384;

View File

@@ -2,6 +2,7 @@ use {client, frame, server, proto};
use frame::Reason;
use codec::{SendError, RecvError};
use frame::DEFAULT_INITIAL_WINDOW_SIZE;
use proto::*;
use http::Request;

View File

@@ -30,6 +30,4 @@ pub type PingPayload = [u8; 8];
pub type WindowSize = u32;
// Constants
// TODO: Move these into `frame`
pub const DEFAULT_INITIAL_WINDOW_SIZE: WindowSize = 65_535;
pub const MAX_WINDOW_SIZE: WindowSize = (1 << 31) - 1;

View File

@@ -281,6 +281,8 @@ impl<B, P> Prioritize<B, P>
// If data is buffered, then schedule the stream for execution
if stream.buffered_send_data > 0 {
debug_assert!(stream.send_flow.available() > 0);
debug_assert!(!stream.pending_send.is_empty());
self.pending_send.push(stream);
}
}
@@ -382,6 +384,7 @@ impl<B, P> Prioritize<B, P>
// If needed, schedule the sender
if stream.send_flow.available() > 0 {
debug_assert!(!stream.pending_send.is_empty());
self.pending_send.push(stream);
}
}
@@ -404,6 +407,7 @@ impl<B, P> Prioritize<B, P>
match self.pending_send.pop(store) {
Some(mut stream) => {
trace!("pop_frame; stream={:?}", stream.id);
debug_assert!(!stream.pending_send.is_empty());
let frame = match stream.pending_send.pop_front(&mut self.buffer).unwrap() {
Frame::Data(mut frame) => {
@@ -456,6 +460,10 @@ impl<B, P> Prioritize<B, P>
trace!(" -- updating stream flow --");
stream.send_flow.send_data(len as WindowSize);
// Decrement the stream's buffered data counter
debug_assert!(stream.buffered_send_data >= len as u32);
stream.buffered_send_data -= len as u32;
// Assign the capacity back to the connection that
// was just consumed from the stream in the previous
// line.