diff --git a/src/ssb.c b/src/ssb.c index bbb3fb8f..de3f974c 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -665,7 +665,7 @@ static void _tf_ssb_connection_box_stream_send(tf_ssb_connection_t* connection, static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connection) { - while ((connection->active_write_count == 0 || connection->closing) && connection->scheduled_count && connection->scheduled) + while (((connection->active_write_count == 0 && connection->read_back_pressure == 0) || connection->closing) && connection->scheduled_count && connection->scheduled) { tf_ssb_connection_scheduled_t scheduled = connection->scheduled[0]; memmove(connection->scheduled, connection->scheduled + 1, sizeof(tf_ssb_connection_scheduled_t) * (connection->scheduled_count - 1)); @@ -4376,6 +4376,7 @@ void tf_ssb_connection_adjust_read_backpressure(tf_ssb_connection_t* connection, const int k_threshold = 256; int old_pressure = connection->read_back_pressure; connection->read_back_pressure += delta; + _tf_ssb_connection_dispatch_scheduled(connection); if (!connection->closing) { if (old_pressure < k_threshold && connection->read_back_pressure >= k_threshold)