From 4ff351438e6e7da673aaef249b96e6dc2bea233a Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Mon, 30 Sep 2024 02:08:18 +0200 Subject: [PATCH] MHD_upgraded_send(): do not wait for socket readyness if all data have been sent --- src/mhd2/upgrade_net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mhd2/upgrade_net.c b/src/mhd2/upgrade_net.c index 7c0b47ad..e20fa3ed 100644 --- a/src/mhd2/upgrade_net.c +++ b/src/mhd2/upgrade_net.c @@ -343,7 +343,7 @@ MHD_upgraded_send (struct MHD_UpgradeHandle *MHD_RESTRICT urh, finish_time_set = false; wait_indefinitely = (MHD_WAIT_INDEFINITELY <= max_wait_millisec); - while (*sent_size != send_buf_size) + while (1) { enum mhd_SocketError res; size_t last_block_size; @@ -359,11 +359,15 @@ MHD_upgraded_send (struct MHD_UpgradeHandle *MHD_RESTRICT urh, push_data, &last_block_size); if (mhd_SOCKET_ERR_NO_ERROR == res) + { *sent_size += last_block_size; + if (send_buf_size == *sent_size) + break; + } else if (mhd_SOCKET_ERR_IS_HARD (res)) { if (0 != *sent_size) - return MHD_SC_OK; + break; if (mhd_SOCKET_ERR_REMT_DISCONN == res) return MHD_SC_UPGRADED_NET_CONN_CLOSED;