Skip to content

Commit

Permalink
fix: enhance tcp_mux_send_win_update_fin function with input validati…
Browse files Browse the repository at this point in the history
…on and debug logging

Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
  • Loading branch information
liudf0716 committed Nov 13, 2024
1 parent 4bd9af8 commit 41232d7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tcpmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,21 @@ void tcp_mux_send_win_update_ack(struct bufferevent *bout, uint32_t stream_id,
* @param stream_id The ID of the stream for which the window update with FIN flag is sent.
*/
void tcp_mux_send_win_update_fin(struct bufferevent *bout, uint32_t stream_id) {
if (!tcp_mux_flag())
// Early return if TCP multiplexing is disabled
if (!tcp_mux_flag()) {
debug(LOG_DEBUG, "TCP multiplexing is disabled");
return;
}

// Validate bufferevent
if (!bout) {
debug(LOG_ERR, "Invalid bufferevent for FIN");
return;
}

// Send window update with FIN flag
tcp_mux_send_win_update(bout, FIN, stream_id, 0);
debug(LOG_DEBUG, "Sent FIN for stream %u", stream_id);
}

/**
Expand Down

0 comments on commit 41232d7

Please sign in to comment.