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_sent_total;
// uint32_t bytes_received_total; // Not used // uint32_t bytes_received_total; // Not used
uint32_t retransmissions_count; uint32_t retransmissions_count;
// uint32_t bytes_sent_norx; // сколько отправили байт без единого ответного пакета (для детекции запроса реконнекта)
// Window and inflight management // Window and inflight management
uint32_t unacked_bytes; // Current inflight bytes 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 // Try normal decryption first if we have an established link with session keys
// This is the common case for data packets and responses // This is the common case for data packets and responses
if (link) { // if (link) {
link->recv_keepalive = 1; // Link is up after successful initialization // link->recv_keepalive = 1; // Link is up after successful initialization - не ставим ап от неизвестных пакетов
} // }
if (link!=NULL && link->etcp!=NULL && link->etcp->crypto_ctx.session_ready) { if (link!=NULL && link->etcp!=NULL && link->etcp->crypto_ctx.session_ready) {
// DEBUG_INFO(DEBUG_CATEGORY_ETCP, "Decrypt start (normal)"); // 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; 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; new_conn=1;
conn=etcp_connection_create(e_sock->instance); 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; }// облом 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]; } *ack_repl_hdr=(void*)&pkt->data[0];
// Set response code: 0x03 (with reset) or 0x05 (without reset) // 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 ack_repl_hdr->code = ETCP_INIT_RESPONSE; // 0x03 - with reset
} else { } else {
ack_repl_hdr->code = ETCP_INIT_RESPONSE_NOINIT; // 0x05 - without reset 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; return;
process_decrypted: 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; } 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->data_len=pkt_len-3;
pkt->noencrypt_len=0; pkt->noencrypt_len=0;
@ -1066,17 +1066,17 @@ process_decrypted:
link->initialized = 1;// получен init response (client) link->initialized = 1;// получен init response (client)
// link->link_status = 1; // Link is up after successful initialization // link->link_status = 1; // Link is up after successful initialization
loadbalancer_link_ready(link); 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", 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->etcp->log_name, link, link->local_link_id, link->recv_keepalive, link->remote_keepalive, link->link_status, link->keepalive_interval);
// Start keepalive timer // Start keepalive timer
etcp_link_send_keepalive(link); etcp_link_send_keepalive(link);
if (!link->keepalive_timer && link->keepalive_interval > 0) { 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_timer = uasync_set_timeout(link->etcp->instance->ua,
link->keepalive_interval * 10, link->keepalive_interval * 10,
link, keepalive_timer_cb); 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); loadbalancer_link_ready(link);

Loading…
Cancel
Save