fix: INIT reset logic — reset only on session change or got_initial_pkt, always sync session_id
This commit is contained in:
1 parent
58df4d8571
commit
beed7a4e07
2 files changed
+20
-37
No files matched your search
+19
-36
@@ -1472,7 +1472,7 @@ static int handle_init_response_client(struct ETCP_SOCKET* e_sock, struct ETCP_D
|
||||
link->init_timer = NULL;
|
||||
}
|
||||
|
||||
if (pkt_code == ETCP_INIT_RESPONSE && !link->etcp->reset_done) {
|
||||
if (pkt_code == ETCP_INIT_RESPONSE && link->etcp->got_initial_pkt) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[%s] REINIT from client: INIT_RESPONSE(0x03) received, reinit conn=%p",
|
||||
link->etcp->log_name, link->etcp);
|
||||
etcp_conn_reinit(link->etcp);
|
||||
@@ -1779,25 +1779,15 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
conn->log_name);
|
||||
}
|
||||
|
||||
// Normal reinit check (skip if reset_done=1 unless session_id changed)
|
||||
if (!conn->reset_done) {
|
||||
if (code == ETCP_INIT_REQUEST || conn->session_id != session_id || !conn->got_initial_pkt) {
|
||||
send_reset = 1;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT existing link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d",
|
||||
conn->log_name, code, conn->session_id, session_id, conn->got_initial_pkt, conn->initialized, conn->links_up);
|
||||
conn->session_id = session_id;
|
||||
etcp_conn_reinit(conn);
|
||||
}
|
||||
} else if (conn->session_id != session_id) {
|
||||
send_reset = 1;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT existing link (session changed): sess=%08x→%08x",
|
||||
conn->log_name, conn->session_id, session_id);
|
||||
conn->session_id = session_id;
|
||||
etcp_conn_reinit(conn);
|
||||
} else {
|
||||
send_reset = 0;
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "same session_id, skip reinit");
|
||||
}
|
||||
// Always sync session_id; reset if new session or data was flowing
|
||||
{ int sess_changed = (conn->session_id != session_id);
|
||||
conn->session_id = session_id;
|
||||
if (sess_changed || conn->got_initial_pkt) {
|
||||
send_reset = 1;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT existing link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d",
|
||||
conn->log_name, code, conn->session_id, session_id, conn->got_initial_pkt, conn->initialized, conn->links_up);
|
||||
etcp_conn_reinit(conn);
|
||||
} }
|
||||
}
|
||||
|
||||
// Cancel existing timers
|
||||
@@ -1834,22 +1824,15 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Normal reinit check (skip if reset_done=1 unless session_id changed)
|
||||
if (!conn->reset_done) {
|
||||
if (code == ETCP_INIT_REQUEST || conn->session_id != session_id || !conn->got_initial_pkt) {
|
||||
send_reset = 1;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT new link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d",
|
||||
conn->log_name, code, conn->session_id, session_id, conn->got_initial_pkt, conn->initialized, conn->links_up);
|
||||
conn->session_id = session_id;
|
||||
etcp_conn_reinit(conn);
|
||||
}
|
||||
} else if (conn->session_id != session_id) {
|
||||
send_reset = 1;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT new link (session changed): sess=%08x→%08x",
|
||||
conn->log_name, conn->session_id, session_id);
|
||||
conn->session_id = session_id;
|
||||
etcp_conn_reinit(conn);
|
||||
}
|
||||
// Always sync session_id; reset if new session or data was flowing
|
||||
{ int sess_changed = (conn->session_id != session_id);
|
||||
conn->session_id = session_id;
|
||||
if (sess_changed || conn->got_initial_pkt) {
|
||||
send_reset = 1;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] REINIT new link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d",
|
||||
conn->log_name, code, conn->session_id, session_id, conn->got_initial_pkt, conn->initialized, conn->links_up);
|
||||
etcp_conn_reinit(conn);
|
||||
} }
|
||||
}
|
||||
link->keepalive_interval=(req->keepalive[0]<<8) | req->keepalive[1];
|
||||
link->recovery_interval=((req->recovery[0]<<8) | req->recovery[1])*100;// timebase в link, timebase/100 в кодограмме
|
||||
|
||||
Reference in new issue
Block a user