etcp: убрать ложный reinit по gop (got_initial_pkt)
reinit должен происходить только при смене reset_id пира (etcp_conn_apply_peer_reset_id). gop-проверка 'dirty vs clean' на догоняющем TCP-линке давала ложный reinit и рвала соединение (JOIN_INFO_RESP терялся). Удалён peer_got_initial_pkt из stcp_link (стал не нужен).
This commit is contained in:
1 parent
ebad30e919
commit
f74e3eaafa
3 files changed
+4
-18
No files matched your search
@@ -1174,17 +1174,11 @@ void etcp_link_enter_ready_tcp(struct ETCP_LINK *link) {
|
||||
(void*)link, (void*)etcp, (void*)etcp->instance, (void*)(etcp->instance ? etcp->instance->ua : NULL),
|
||||
etcp->state, (void*)link->tcp_link);
|
||||
|
||||
/* Синхронизация got_initial_pkt: если я грязный (1) а пир чистый (0) → сбросить */
|
||||
/* reinit только при смене reset_id пира — синхронизация через etcp_conn_apply_peer_reset_id */
|
||||
if (link->tcp_link) {
|
||||
uint8_t peer_gop = stcp_link_get_peer_got_initial_pkt(link->tcp_link);
|
||||
uint64_t peer_rid = stcp_link_get_peer_reset_id(link->tcp_link);
|
||||
if (etcp->got_initial_pkt == 1 && peer_gop == 0) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[%s] TCP ready: I'm dirty (gop=1) but peer clean (gop=0) → reinit",
|
||||
etcp->log_name);
|
||||
etcp_conn_reinit(etcp, "tcp peer clean");
|
||||
}
|
||||
etcp_conn_apply_peer_reset_id(etcp, peer_rid);
|
||||
if (etcp->state == 2) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "enter_ready_tcp: conn DELETED after reinit/apply_reset, link=%p", (void*)link); return; }
|
||||
if (etcp->state == 2) { DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "enter_ready_tcp: conn DELETED after apply_reset, link=%p", (void*)link); return; }
|
||||
|
||||
link->peer_device_type = stcp_link_get_peer_device_type(link->tcp_link);
|
||||
{ uint16_t peer_ka = stcp_link_get_peer_keepalive_interval(link->tcp_link);
|
||||
|
||||
@@ -46,7 +46,6 @@ struct stcp_link {
|
||||
struct ll_queue *saved_rx_queue; // saved rx_queue for pre-closed conn cleanup
|
||||
uint8_t conn_pre_closed; // 1 = conn already CLOSED before stcp_link_close
|
||||
|
||||
uint8_t peer_got_initial_pkt; // received from peer during handshake
|
||||
uint64_t peer_reset_id; // received from peer during handshake (reset epoch)
|
||||
uint8_t peer_device_type; // CLIENT_TYPE_* from peer handshake
|
||||
uint16_t peer_keepalive_interval; // keepalive interval from peer handshake
|
||||
@@ -112,7 +111,6 @@ static void server_accept_cb(struct stcp_conn *conn, void *arg) {
|
||||
link->ua = ss->inst->ua;
|
||||
link->ready = 1;
|
||||
link->conn = conn;
|
||||
link->peer_got_initial_pkt = conn->peer_got_initial_pkt;
|
||||
link->peer_reset_id = conn->peer_reset_id;
|
||||
link->peer_device_type = conn->peer_device_type;
|
||||
link->peer_keepalive_interval = conn->peer_keepalive_interval;
|
||||
@@ -139,7 +137,6 @@ static void client_ready_cb(struct stcp_conn *conn, void *arg) {
|
||||
if (!conn) return;
|
||||
link->ready = 1;
|
||||
link->conn = conn;
|
||||
link->peer_got_initial_pkt = conn->peer_got_initial_pkt;
|
||||
link->peer_reset_id = conn->peer_reset_id;
|
||||
link->peer_device_type = conn->peer_device_type;
|
||||
link->peer_keepalive_interval = conn->peer_keepalive_interval;
|
||||
@@ -157,11 +154,11 @@ static void client_ready_cb(struct stcp_conn *conn, void *arg) {
|
||||
|
||||
{
|
||||
const struct sockaddr_storage *ra = link->etcp_link ? &link->etcp_link->remote_addr : NULL;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "stcp_link: client handshake OK [%s] link=%d addr=%s gop=%d rid=%016llx",
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "stcp_link: client handshake OK [%s] link=%d addr=%s rid=%016llx",
|
||||
link->etcp_conn ? link->etcp_conn->log_name : "?",
|
||||
link->etcp_link ? link->etcp_link->local_link_id : -1,
|
||||
ra ? sockaddr_storage_to_str(ra).str : "?",
|
||||
link->peer_got_initial_pkt, (unsigned long long)link->peer_reset_id);
|
||||
(unsigned long long)link->peer_reset_id);
|
||||
}
|
||||
if (link->etcp_link) etcp_link_enter_ready_tcp(link->etcp_link);
|
||||
if (link->on_ready_cb) link->on_ready_cb(link, link->ready_arg);
|
||||
@@ -386,10 +383,6 @@ const uint8_t *stcp_link_get_peer_ed25519_pubkey(struct stcp_link *link) {
|
||||
return link && link->conn && link->conn->peer_ed25519_set ? link->conn->peer_ed25519_pubkey : NULL;
|
||||
}
|
||||
|
||||
uint8_t stcp_link_get_peer_got_initial_pkt(struct stcp_link *link) {
|
||||
return link ? link->peer_got_initial_pkt : 0;
|
||||
}
|
||||
|
||||
uint64_t stcp_link_get_peer_reset_id(struct stcp_link *link) {
|
||||
return link ? link->peer_reset_id : 0;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ void stcp_link_set_on_ready(struct stcp_link *link, stcp_link_cb cb, void *arg);
|
||||
void stcp_link_set_on_close(struct stcp_link *link, void (*cb)(struct stcp_link *link, int err, void *arg), void *arg);
|
||||
const uint8_t *stcp_link_get_peer_pubkey(struct stcp_link *link);
|
||||
const uint8_t *stcp_link_get_peer_ed25519_pubkey(struct stcp_link *link);
|
||||
uint8_t stcp_link_get_peer_got_initial_pkt(struct stcp_link *link);
|
||||
uint64_t stcp_link_get_peer_reset_id(struct stcp_link *link);
|
||||
uint8_t stcp_link_get_peer_device_type(struct stcp_link *link);
|
||||
uint16_t stcp_link_get_peer_keepalive_interval(struct stcp_link *link);
|
||||
|
||||
Reference in new issue
Block a user