Skip to content

Commit

Permalink
fix: enhance tcp_mux_send_win_update_syn 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 cb07511 commit 0ff67f0
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 @@ -261,11 +261,34 @@ static void tcp_mux_send_win_update(struct bufferevent *bout,
* @param bout The bufferevent to send the window update on.
* @param stream_id The ID of the stream to send the window update for.
*/
/**
* @brief Sends a window update with SYN flag for a TCP multiplexed stream.
*
* This function sends a window update message with the SYN flag set for
* a specified stream. 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 send the update for
*
* @note Function silently returns if TCP multiplexing is disabled
* or if bufferevent is invalid
*/
void tcp_mux_send_win_update_syn(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 SYN");
return;
}

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

/**
Expand Down

0 comments on commit 0ff67f0

Please sign in to comment.