etcp_connections: force reinit when client sends ETCP_INIT_REQUEST (reset)
Server now checks both code==ETCP_INIT_REQUEST and session_id mismatch to decide send_reset. Previously only session_id was checked, so if session matched (both sides had 00000000), reinit was skipped even when client explicitly requested reset (code 0x02). Client side already correct: handle_init_response_client:1473 calls etcp_conn_reinit if pkt_code==ETCP_INIT_RESPONSE (0x03).
This commit is contained in:
1 parent
1d29cab751
commit
41e0736b75
1 file changed
+10
-10
+10
-10
@@ -1727,14 +1727,14 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
// For CHANNEL_INIT (0x04): if link already initialized - no reset, otherwise reset
|
||||
// For INIT_REQUEST (0x02): always reset
|
||||
// Check session_id: if same - no reinit, if different - client restarted, do reinit
|
||||
if (conn->session_id == session_id) {
|
||||
send_reset = 0; // Same session, no reinit needed
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "same session_id, skip reinit");
|
||||
} else {
|
||||
send_reset = 1; // New session or uninitialized link - send reset
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "new session_id %08x (was %08x), do reinit", session_id, conn->session_id);
|
||||
if (code == ETCP_INIT_REQUEST || conn->session_id != session_id) {
|
||||
send_reset = 1; // Client explicitly requested reset, or new session
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "do reinit (code=%02x session was %08x now %08x)", code, conn->session_id, session_id);
|
||||
conn->session_id = session_id;
|
||||
etcp_conn_reinit(conn);
|
||||
} else {
|
||||
send_reset = 0; // Same session, no reinit needed
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "same session_id, skip reinit");
|
||||
}
|
||||
|
||||
// Cancel existing timers
|
||||
@@ -1752,10 +1752,10 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
|
||||
link->remote_only_local = req->only_local;
|
||||
link->remote_type = req->type;
|
||||
|
||||
// For new links: check session_id to avoid false reinit
|
||||
if (conn->session_id != session_id) {
|
||||
send_reset = 1; // New session or uninitialized link - send reset
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "new session_id %08x (was %08x) for new link, do reinit", session_id, conn->session_id);
|
||||
// For new links: reset if client requested or session changed
|
||||
if (code == ETCP_INIT_REQUEST || conn->session_id != session_id) {
|
||||
send_reset = 1;
|
||||
DEBUG_TRACE(DEBUG_CATEGORY_CONNECTION, "do reinit for new link (code=%02x session was %08x now %08x)", code, conn->session_id, session_id);
|
||||
conn->session_id = session_id;
|
||||
etcp_conn_reinit(conn);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user