Skip to content

Commit

Permalink
fix: enhance tcp_mux_send_win_update_rst 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 2b2aa9d commit 4bd9af8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tcpmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,34 @@ void tcp_mux_send_win_update_fin(struct bufferevent *bout, uint32_t stream_id) {
* @param bout Pointer to the bufferevent structure used for sending the update.
* @param stream_id The ID of the stream for which the window update is being sent.
*/
/**
* @brief Sends a window update with RST flag for a TCP multiplexed stream
*
* This function sends a window update message with the RST (reset) flag set for
* the specified stream ID. The message is only sent if TCP multiplexing is enabled.
*
* @param bout The bufferevent to write the window update to
* @param stream_id The ID of the stream to reset
*
* @note Function silently returns if TCP multiplexing is disabled
* or if bufferevent is invalid
*/
void tcp_mux_send_win_update_rst(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 RST");
return;
}

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

/**
Expand Down

0 comments on commit 4bd9af8

Please sign in to comment.