Skip to content

Commit 41232d7

Browse files
committed
fix: enhance tcp_mux_send_win_update_fin function with input validation and debug logging
Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
1 parent 4bd9af8 commit 41232d7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tcpmux.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,21 @@ void tcp_mux_send_win_update_ack(struct bufferevent *bout, uint32_t stream_id,
297297
* @param stream_id The ID of the stream for which the window update with FIN flag is sent.
298298
*/
299299
void tcp_mux_send_win_update_fin(struct bufferevent *bout, uint32_t stream_id) {
300-
if (!tcp_mux_flag())
300+
// Early return if TCP multiplexing is disabled
301+
if (!tcp_mux_flag()) {
302+
debug(LOG_DEBUG, "TCP multiplexing is disabled");
303+
return;
304+
}
305+
306+
// Validate bufferevent
307+
if (!bout) {
308+
debug(LOG_ERR, "Invalid bufferevent for FIN");
301309
return;
310+
}
302311

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

306317
/**

0 commit comments

Comments
 (0)