Commit b60a47e7 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Do not wait for timeout when all connections attempts have failed

parent bd3b61f9
......@@ -200,6 +200,9 @@ enum {
/* A new connection has been established to the remote peer (event data is the cnxctx object) */
,FDEVP_CNX_ESTABLISHED
/* A connection attempt (initiator side) has failed */
,FDEVP_CNX_FAILED
/* The PSM state is expired */
,FDEVP_PSM_TIMEOUT
......@@ -218,6 +221,7 @@ const char * fd_pev_str(int event) \
case_str(FDEVP_CNX_EP_CHANGE); \
case_str(FDEVP_CNX_INCOMING); \
case_str(FDEVP_CNX_ESTABLISHED); \
case_str(FDEVP_CNX_FAILED); \
case_str(FDEVP_PSM_TIMEOUT); \
} \
TRACE_DEBUG(FULL, "Unknown event : %d", event); \
......
......@@ -60,6 +60,7 @@ int main(int argc, char * argv[])
pthread_t sig_th;
sigset_t sig_all;
/* Block all signals */
memset(fd_g_config, 0, sizeof(struct fd_config));
sigfillset(&sig_all);
CHECK_POSIX( pthread_sigmask(SIG_BLOCK, &sig_all, NULL) );
......
......@@ -217,6 +217,7 @@ static void * connect_thr(void * arg)
if (FD_IS_LIST_EMPTY(&peer->p_connparams)) {
/* We encountered an error or we have looped over all the addresses of the peer. */
TRACE_DEBUG(INFO, "Unable to connect to the peer %s, aborting attempts for now.", peer->p_hdr.info.pi_diamid);
CHECK_FCT_DO( fd_event_send(peer->p_events, FDEVP_CNX_FAILED, 0, NULL), goto fatal_error );
return NULL;
}
}
......
......@@ -606,6 +606,36 @@ psm_loop:
goto psm_loop;
}
/* A new connection has been established with the remote peer */
if (event == FDEVP_CNX_FAILED) {
struct cnxctx * cnx = ev_data;
/* Release the resources of the connecting thread */
CHECK_POSIX_DO( pthread_join( peer->p_ini_thr, NULL), /* ignore, it is not a big deal */);
peer->p_ini_thr = (pthread_t)NULL;
switch (peer->p_hdr.info.runtime.pir_state) {
case STATE_WAITCNXACK_ELEC:
/* Abort the initiating side */
fd_p_cnx_abort(peer, 0);
/* Process the receiver side */
CHECK_FCT_DO( fd_p_ce_process_receiver(peer), goto psm_end );
break;
case STATE_WAITCNXACK:
/* Go back to CLOSE */
fd_psm_cleanup(peer, 0);
fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc);
break;
default:
/* Just ignore */
TRACE_DEBUG(FULL, "Connection attempt failed but current state is %s, ignoring...", STATE_STR(peer->p_hdr.info.runtime.pir_state));
}
goto psm_loop;
}
/* The timeout for the current state has been reached */
if (event == FDEVP_PSM_TIMEOUT) {
switch (peer->p_hdr.info.runtime.pir_state) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment