@ -1473,7 +1473,7 @@ static int handle_init_response_client(struct ETCP_SOCKET* e_sock, struct ETCP_D
link - > init_timer = NULL ;
link - > init_timer = NULL ;
}
}
if ( pkt_code = = ETCP_INIT_RESPONSE ) {
if ( pkt_code = = ETCP_INIT_RESPONSE & & ! link - > etcp - > reset_done ) {
DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT from client: INIT_RESPONSE(0x03) received, reinit conn=%p " ,
DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT from client: INIT_RESPONSE(0x03) received, reinit conn=%p " ,
link - > etcp - > log_name , link - > etcp ) ;
link - > etcp - > log_name , link - > etcp ) ;
etcp_conn_reinit ( link - > etcp ) ;
etcp_conn_reinit ( link - > etcp ) ;
@ -1748,10 +1748,11 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
// Check session_id: if same - no reinit, if different - client restarted, do reinit
// Check session_id: if same - no reinit, if different - client restarted, do reinit
if ( code = = ETCP_INIT_REQUEST | | conn - > session_id ! = session_id | | ! conn - > got_initial_pkt ) {
if ( code = = ETCP_INIT_REQUEST | | conn - > session_id ! = session_id | | ! conn - > got_initial_pkt ) {
send_reset = 1 ; // Client explicitly requested reset, or new session, or server waiting for first packet
send_reset = 1 ; // Client explicitly requested reset, or new session, or server waiting for first packet
DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT existing link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d " ,
DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT existing link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d reset_done=%d " ,
conn - > log_name , code , conn - > session_id , session_id , conn - > got_initial_pkt , conn - > initialized , conn - > links_up ) ;
conn - > log_name , code , conn - > session_id , session_id , conn - > got_initial_pkt , conn - > initialized , conn - > links_up , conn - > reset_done ) ;
conn - > session_id = session_id ;
conn - > session_id = session_id ;
etcp_conn_reinit ( conn ) ;
if ( ! conn - > reset_done ) etcp_conn_reinit ( conn ) ;
else DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT skipped — reset_done=1 " , conn - > log_name ) ;
} else {
} else {
send_reset = 0 ; // Same session, no reinit needed
send_reset = 0 ; // Same session, no reinit needed
DEBUG_TRACE ( DEBUG_CATEGORY_CONNECTION , " same session_id, skip reinit " ) ;
DEBUG_TRACE ( DEBUG_CATEGORY_CONNECTION , " same session_id, skip reinit " ) ;
@ -1775,10 +1776,11 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) {
// For new links: reset if client requested or session changed
// For new links: reset if client requested or session changed
if ( code = = ETCP_INIT_REQUEST | | conn - > session_id ! = session_id | | ! conn - > got_initial_pkt ) {
if ( code = = ETCP_INIT_REQUEST | | conn - > session_id ! = session_id | | ! conn - > got_initial_pkt ) {
send_reset = 1 ;
send_reset = 1 ;
DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT new link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d " ,
DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT new link: code=0x%02x sess=%08x→%08x got_init=%d initialized=%d links_up=%d reset_done=%d " ,
conn - > log_name , code , conn - > session_id , session_id , conn - > got_initial_pkt , conn - > initialized , conn - > links_up ) ;
conn - > log_name , code , conn - > session_id , session_id , conn - > got_initial_pkt , conn - > initialized , conn - > links_up , conn - > reset_done ) ;
conn - > session_id = session_id ;
conn - > session_id = session_id ;
etcp_conn_reinit ( conn ) ;
if ( ! conn - > reset_done ) etcp_conn_reinit ( conn ) ;
else DEBUG_INFO ( DEBUG_CATEGORY_DEBUG , " [%s] REINIT skipped — reset_done=1 " , conn - > log_name ) ;
}
}
link - > keepalive_interval = ( req - > keepalive [ 0 ] < < 8 ) | req - > keepalive [ 1 ] ;
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 в кодограмме
link - > recovery_interval = ( ( req - > recovery [ 0 ] < < 8 ) | req - > recovery [ 1 ] ) * 100 ; // timebase в link, timebase/100 в кодограмме