@ -336,13 +336,19 @@ static void etcp_on_up(struct ETCP_CONN* etcp) {
etcp - > crypto_ctx . peer_public_key [ 2 ] , etcp - > crypto_ctx . peer_public_key [ 3 ] ) ;
}
static void etcp_on_down ( struct ETCP_CONN * etcp ) {
static void etcp_on_down ( struct ETCP_CONN * etcp , struct ETCP_LINK * down_link ) {
char links_str [ 256 ] = { 0 } ; int pp = 0 ;
for ( struct ETCP_LINK * l = etcp - > links ; l ; l = l - > next ) {
if ( l = = down_link ) continue ;
if ( pp ) pp + = snprintf ( links_str + pp , sizeof ( links_str ) - pp , " , " ) ;
pp + = snprintf ( links_str + pp , sizeof ( links_str ) - pp , " %s " , sockaddr_storage_to_str ( & l - > remote_addr ) . str ) ;
}
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTION , " [%s] Connection DOWN — links: %s " , etcp - > log_name , pp ? links_str : " (none) " ) ;
if ( down_link )
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTION , " [%s] Connection DOWN — link %s lost%s%s " ,
etcp - > log_name , sockaddr_storage_to_str ( & down_link - > remote_addr ) . str ,
pp > 0 ? " , remaining: " : " " , links_str ) ;
else
DEBUG_INFO ( DEBUG_CATEGORY_CONNECTION , " [%s] Connection DOWN — closing, links: %s " , etcp - > log_name , pp ? links_str : " (none) " ) ;
etcp_cbk_fire ( etcp , ETCP_CBK_EVENT_DOWN ) ;
etcp_fire_conn_status ( etcp , ETCP_CONN_STATUS_DOWN ) ;
}
@ -398,7 +404,7 @@ void etcp_connection_close(struct ETCP_CONN* etcp) {
// === PHASE 1: detach from external world ===
if ( etcp - > links_up ! = 0 ) { etcp - > links_up = 0 ; etcp_on_down ( etcp ) ; }
if ( etcp - > links_up ! = 0 ) { etcp - > links_up = 0 ; etcp_on_down ( etcp , NULL ) ; }
// Cancel active timers
if ( etcp - > retrans_timer ) { uasync_cancel_timeout ( etcp - > instance - > ua , etcp - > retrans_timer ) ; etcp - > retrans_timer = NULL ; }
@ -561,7 +567,7 @@ void etcp_conn_reset(struct ETCP_CONN* etcp) {
etcp_on_up ( etcp ) ;
} else {
DEBUG_TRACE ( DEBUG_CATEGORY_ETCP , " reset conn: set link down/up " ) ;
etcp_on_down ( etcp ) ;
etcp_on_down ( etcp , NULL ) ;
etcp_on_up ( etcp ) ;
}
} else {
@ -569,7 +575,7 @@ void etcp_conn_reset(struct ETCP_CONN* etcp) {
if ( etcp - > links_up ) {
etcp - > links_up = 0 ;
etcp - > setup_start_tb = get_time_tb ( ) ;
etcp_on_down ( etcp ) ;
etcp_on_down ( etcp , NULL ) ;
}
}
@ -690,7 +696,7 @@ void etcp_update_log_name(struct ETCP_CONN* etcp) {
uint16_t local_id = etcp - > instance - > node_id ;
uint16_t peer_id = etcp - > peer_node_id ;
const char * name = etcp - > name ? etcp - > name : EMPTY_NAME ;
if ( ! name [ 0 ] & & etcp - > instance - > topo_groups & & peer_id ) {
if ( etcp - > instance - > topo_groups & & peer_id ) {
struct TOPO_NODE * ni = topo_node_registry_find ( etcp - > instance - > topo_groups , etcp - > peer_node_id ) ;
if ( ni & & ni - > node_name & & ni - > node_name [ 0 ] ) name = ni - > node_name ;
}
@ -982,7 +988,7 @@ static void send_ack_req_cb(struct ll_queue* q, void* arg) {// etcp->ack_q data
if ( etcp - > tx_state = = ETCP_TX_STATE_DATA_WAIT ) queue_resume_callback ( etcp - > ack_q ) ;
}
*/
void etcp_on_link_down ( struct ETCP_CONN * etcp ) {
void etcp_on_link_down ( struct ETCP_CONN * etcp , struct ETCP_LINK * down_link ) {
DEBUG_TRACE ( DEBUG_CATEGORY_ETCP , " " ) ;
int up = 0 ;
struct ETCP_LINK * link = etcp - > links ;
@ -994,7 +1000,7 @@ void etcp_on_link_down(struct ETCP_CONN* etcp) {
etcp - > links_up = up ;
if ( up = = 0 & & was_up ! = 0 ) {
DEBUG_INFO ( DEBUG_CATEGORY_ETCP , " All links fall down " ) ;
etcp_on_down ( etcp ) ;
etcp_on_down ( etcp , down_link ) ;
}
}