From f25e59e75d8d033f1f5eaa1e7eabb060701f9f27 Mon Sep 17 00:00:00 2001 From: jeka Date: Tue, 3 Mar 2026 18:41:39 +0300 Subject: [PATCH] reset fix --- src/etcp.h | 1 + src/etcp_connections.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/etcp.h b/src/etcp.h index fb875b98f..4f8abc277 100644 --- a/src/etcp.h +++ b/src/etcp.h @@ -111,6 +111,7 @@ struct ETCP_CONN { uint32_t bytes_sent_total; // uint32_t bytes_received_total; // Not used uint32_t retransmissions_count; +// uint32_t bytes_sent_norx; // сколько отправили байт без единого ответного пакета (для детекции запроса реконнекта) // Window and inflight management uint32_t unacked_bytes; // Current inflight bytes diff --git a/src/etcp_connections.c b/src/etcp_connections.c index 1b23e57d9..5f5f4c9e8 100644 --- a/src/etcp_connections.c +++ b/src/etcp_connections.c @@ -785,9 +785,9 @@ static void etcp_connections_read_callback_socket(socket_t sock, void* arg) { // Try normal decryption first if we have an established link with session keys // This is the common case for data packets and responses - if (link) { - link->recv_keepalive = 1; // Link is up after successful initialization - } +// if (link) { +// link->recv_keepalive = 1; // Link is up after successful initialization - не ставим ап от неизвестных пакетов +// } if (link!=NULL && link->etcp!=NULL && link->etcp->crypto_ctx.session_ready) { // DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Decrypt start (normal)"); @@ -859,7 +859,7 @@ static void etcp_connections_read_callback_socket(socket_t sock, void* arg) { } int new_conn=0; - if (!conn || conn->peer_node_id!=peer_id) {// создаём новое + if (!conn || conn->peer_node_id!=peer_id) {// создаём новое подключение [new etcp] new_conn=1; conn=etcp_connection_create(e_sock->instance); if (!conn) { errorcode=55; DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "etcp_connections_read_callback: failed to create connection"); goto ec_fr; }// облом @@ -922,7 +922,7 @@ static void etcp_connections_read_callback_socket(socket_t sock, void* arg) { } *ack_repl_hdr=(void*)&pkt->data[0]; // Set response code: 0x03 (with reset) or 0x05 (without reset) - if (send_reset || ack_hdr->code == ETCP_INIT_REQUEST) { + if (send_reset || new_conn || ack_hdr->code == ETCP_INIT_REQUEST) { ack_repl_hdr->code = ETCP_INIT_RESPONSE; // 0x03 - with reset } else { ack_repl_hdr->code = ETCP_INIT_RESPONSE_NOINIT; // 0x05 - without reset @@ -977,7 +977,7 @@ static void etcp_connections_read_callback_socket(socket_t sock, void* arg) { return; process_decrypted: -// DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Decrypt end"); + DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "Decrypt ok - normal pkt"); if (pkt_len<3) { errorcode=46; DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "etcp_connections_read_callback: decrypted packet too small, size=%zu", pkt_len); goto ec_fr; } pkt->data_len=pkt_len-3; pkt->noencrypt_len=0; @@ -1066,17 +1066,17 @@ process_decrypted: link->initialized = 1;// получен init response (client) // link->link_status = 1; // Link is up after successful initialization loadbalancer_link_ready(link); - DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] Link %p (local_id=%d) initialized and marked as UP (client): rk=%d lk=%d up=%d", - link->etcp->log_name, link, link->local_link_id, link->recv_keepalive, link->remote_keepalive, link->link_status); + DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] Link %p (local_id=%d) initialized and marked as UP (client): rk=%d lk=%d up=%d ki=%d", + link->etcp->log_name, link, link->local_link_id, link->recv_keepalive, link->remote_keepalive, link->link_status, link->keepalive_interval); // Start keepalive timer etcp_link_send_keepalive(link); if (!link->keepalive_timer && link->keepalive_interval > 0) { + DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "[%s] Keepalive timer started on link %p (interval=%d ms)", + link->etcp->log_name, link, link->keepalive_interval); link->keepalive_timer = uasync_set_timeout(link->etcp->instance->ua, link->keepalive_interval * 10, link, keepalive_timer_cb); - DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "[%s] Keepalive timer started on link %p (interval=%d ms)", - link->etcp->log_name, link, link->keepalive_interval); } loadbalancer_link_ready(link);