From 8030161ea68fb2857e439f5b5d24972ca231cc8a Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 27 Mar 2026 15:11:05 +0300 Subject: [PATCH] -warn --- lib/u_async.c | 3 ++- src/etcp.c | 22 +++++++++++++++------- src/secure_channel.c | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/u_async.c b/lib/u_async.c index 334e19e..f3837bf 100644 --- a/lib/u_async.c +++ b/lib/u_async.c @@ -941,7 +941,8 @@ void uasync_poll(struct UASYNC* ua, int timeout_tb) { #ifdef _WIN32 Sleep(timeout_ms); #else - usleep(timeout_ms * 1000); + struct timespec ts = { timeout_ms / 1000, (timeout_ms % 1000) * 1000000 }; + nanosleep(&ts, NULL); #endif } process_timeouts(ua); diff --git a/src/etcp.c b/src/etcp.c index 0590d71..f087722 100644 --- a/src/etcp.c +++ b/src/etcp.c @@ -580,7 +580,8 @@ static void ack_timeout_check(struct ETCP_CONN* etcp) { struct ll_entry* current; - while (current = etcp->input_wait_ack->head) { + current = etcp->input_wait_ack->head; + while (current) { struct INFLIGHT_PACKET* pkt = (struct INFLIGHT_PACKET*)current; int64_t elapsed = now - pkt->last_timestamp; @@ -611,6 +612,7 @@ static void ack_timeout_check(struct ETCP_CONN* etcp) { DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] retransmission timer set for %llu units", etcp->log_name, next_timeout); return; } + current = etcp->input_wait_ack->head; } queue_resume_callback(etcp->input_wait_ack); } @@ -696,8 +698,10 @@ static void etcp_conn_process_send_queue(struct ETCP_CONN* etcp) {// вызыв DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] TX state: %d (link not ready, skip send)", etcp->log_name, etcp->tx_state); return; } - while(dgram = etcp_request_pkt(etcp)) { + dgram = etcp_request_pkt(etcp); + while(dgram) { etcp_loadbalancer_send(dgram); + dgram = etcp_request_pkt(etcp); } } @@ -933,15 +937,19 @@ void etcp_ack_recv(struct ETCP_CONN* etcp, uint32_t seq, uint16_t ts, uint16_t d // Find the acknowledged packet in the wait_ack queue struct INFLIGHT_PACKET* acked_pkt; - if (acked_pkt = (struct INFLIGHT_PACKET*)queue_find_data_by_id(etcp->input_wait_ack, seq)) { + acked_pkt = (struct INFLIGHT_PACKET*)queue_find_data_by_id(etcp->input_wait_ack, seq); + if (acked_pkt) { etcp->cnt_ack_hit_inf++; queue_remove_data(etcp->input_wait_ack, (struct ll_entry*)acked_pkt); } - else if ( acked_pkt = (struct INFLIGHT_PACKET*)queue_find_data_by_id(etcp->input_send_q, seq) ) { - etcp->cnt_ack_hit_sndq++; - queue_remove_data(etcp->input_send_q, (struct ll_entry*)acked_pkt); + else { + acked_pkt = (struct INFLIGHT_PACKET*)queue_find_data_by_id(etcp->input_send_q, seq); + if (acked_pkt) { + etcp->cnt_ack_hit_sndq++; + queue_remove_data(etcp->input_send_q, (struct ll_entry*)acked_pkt); } - else etcp->cnt_ack_miss++; + else etcp->cnt_ack_miss++; + } if (!acked_pkt) { // Packet might be already acknowledged or not found diff --git a/src/secure_channel.c b/src/secure_channel.c index a860cf1..840741b 100644 --- a/src/secure_channel.c +++ b/src/secure_channel.c @@ -24,6 +24,7 @@ // The core logic (e.g., nonce building, CRC, session key derivation as memcpy, counters, etc.) remains unchanged. #ifdef USE_OPENSSL +#include #include #include #include