Fix flow control bug (#177)
This patch fixes a bug that prevents sent data from being flushed to the socket. When data is sent, the task managing the connection must be notified. A guard exists that prevents unnecessary notification of the connection when the stream does not have any send capacity. However, this guard was buggy. Instead of notifying the connection if *any* data can be sent, it notified the connection only when *all* data could be sent. This patch fixes the check as well as adds some tests that ensure the connection task is notified.
This commit is contained in:
@@ -158,7 +158,15 @@ impl Prioritize {
|
||||
stream.buffered_send_data
|
||||
);
|
||||
|
||||
if stream.send_flow.available() >= stream.buffered_send_data {
|
||||
// The `stream.buffered_send_data == 0` check is here so that, if a zero
|
||||
// length data frame is queued to the front (there is no previously
|
||||
// queued data), it gets sent out immediately even if there is no
|
||||
// available send window.
|
||||
//
|
||||
// Sending out zero length data frames can be done to singal
|
||||
// end-of-stream.
|
||||
//
|
||||
if stream.send_flow.available() > 0 || stream.buffered_send_data == 0 {
|
||||
// The stream currently has capacity to send the data frame, so
|
||||
// queue it up and notify the connection task.
|
||||
self.queue_frame(frame.into(), buffer, stream, task);
|
||||
|
||||
Reference in New Issue
Block a user