Browse Source

reset fix

nodeinfo-routing-update
jeka 1 month ago
parent
commit
0ffcfb2f52
  1. 1
      src/etcp.h
  2. 20
      src/etcp_connections.c

1
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

20
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);

Loading…
Cancel
Save