Mercurial > hg > freeDiameter
changeset 49:204718b0fa54
Couple of fixes
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 27 Nov 2009 16:45:32 +0900 |
parents | 2b1cba7e949d |
children | dbba83bafd66 08d8cbeff30b |
files | freeDiameter/p_cnx.c freeDiameter/p_psm.c |
diffstat | 2 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/freeDiameter/p_cnx.c Fri Nov 27 16:32:04 2009 +0900 +++ b/freeDiameter/p_cnx.c Fri Nov 27 16:45:32 2009 +0900 @@ -193,17 +193,30 @@ struct fd_peer * peer = arg; struct cnxctx * cnx = NULL; struct next_conn * nc = NULL; + int rebuilt = 0; TRACE_ENTRY("%p", arg); CHECK_PARAMS_DO( CHECK_PEER(peer), return NULL ); + /* Set the thread name */ + { + char buf[48]; + sprintf(buf, "ConnTo:%.*s", sizeof(buf) - 8, peer->p_hdr.info.pi_diamid); + fd_log_threadname ( buf ); + } + do { - /* Rebuild the list if needed, if it is empty */ + /* Rebuild the list if needed, if it is empty -- but at most once */ if (FD_IS_LIST_EMPTY(&peer->p_connparams)) { - CHECK_FCT_DO( prepare_connection_list(peer), goto fatal_error ); - if (FD_IS_LIST_EMPTY(&peer->p_connparams)) - /* Already logged and peer terminated */ + if (! rebuilt) { + CHECK_FCT_DO( prepare_connection_list(peer), goto fatal_error ); + rebuilt ++; + } + 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); return NULL; + } } /* Attempt connection to the first entry */
--- a/freeDiameter/p_psm.c Fri Nov 27 16:32:04 2009 +0900 +++ b/freeDiameter/p_psm.c Fri Nov 27 16:45:32 2009 +0900 @@ -610,13 +610,13 @@ case STATE_OPEN: case STATE_REOPEN: CHECK_FCT_DO( fd_p_dw_timeout(peer), goto psm_end ); - break; + goto psm_loop; case STATE_CLOSED: CHECK_FCT_DO( fd_psm_change_state(peer, STATE_WAITCNXACK), goto psm_end ); fd_psm_next_timeout(peer, 0, CNX_TIMEOUT); CHECK_FCT_DO( fd_p_cnx_init(peer), goto psm_end ); - break; + goto psm_loop; case STATE_CLOSING: case STATE_SUSPECT: @@ -625,7 +625,7 @@ /* Destroy the connection, restart the timer to a new connection attempt */ 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; + goto psm_loop; case STATE_WAITCNXACK_ELEC: @@ -634,17 +634,12 @@ /* Handle receiver side */ CHECK_FCT_DO( fd_p_ce_process_receiver(peer), goto psm_end ); - break; + goto psm_loop; } } /* Default action : the handling has not yet been implemented. [for debug only] */ TODO("Missing handler in PSM : '%s'\t<-- '%s'", STATE_STR(peer->p_hdr.info.runtime.pir_state), fd_pev_str(event)); - if (event == FDEVP_PSM_TIMEOUT) { - /* We have not handled timeout in this state, let's postpone next alert to avoid flood */ - fd_psm_next_timeout(peer, 0, 60); - } - goto psm_loop; psm_end: