@@ -626,23 +626,40 @@ static int process_data(struct tmux_stream *stream, uint32_t length,
626
626
static int incr_send_window (struct bufferevent * bev ,
627
627
struct tcp_mux_header * tmux_hdr , uint16_t flags ,
628
628
struct tmux_stream * stream ) {
629
- if (!stream ) {
629
+ // Validate input parameters
630
+ if (!bev || !tmux_hdr || !stream ) {
631
+ debug (LOG_ERR , "Invalid parameters in incr_send_window" );
630
632
return 0 ;
631
633
}
632
- uint32_t id = stream -> id ;
633
634
634
- if (!process_flags (flags , stream ))
635
+ // Save stream ID for later use
636
+ uint32_t stream_id = stream -> id ;
637
+
638
+ // Process control flags first
639
+ if (!process_flags (flags , stream )) {
640
+ debug (LOG_ERR , "Failed to process flags for stream %d" , stream_id );
635
641
return 0 ;
642
+ }
636
643
637
- if (!get_stream_by_id (id )) {
644
+ // Verify stream still exists after flag processing
645
+ if (!get_stream_by_id (stream_id )) {
646
+ debug (LOG_DEBUG , "Stream %d no longer exists" , stream_id );
638
647
return 1 ;
639
648
}
640
649
641
- uint32_t length = ntohl (tmux_hdr -> length );
650
+ // Get window increment size
651
+ uint32_t increment = ntohl (tmux_hdr -> length );
642
652
643
- if (stream -> send_window == 0 )
653
+ // Enable read events if window was previously full
654
+ if (stream -> send_window == 0 ) {
655
+ debug (LOG_DEBUG , "Enabling read events for stream %d" , stream_id );
644
656
bufferevent_enable (bev , EV_READ );
645
- stream -> send_window += length ;
657
+ }
658
+
659
+ // Update send window
660
+ stream -> send_window += increment ;
661
+ debug (LOG_DEBUG , "Stream %d send window increased by %u to %u" ,
662
+ stream_id , increment , stream -> send_window );
646
663
647
664
return 1 ;
648
665
}
0 commit comments