Mercurial > hg > freeDiameter
diff freeDiameter/p_cnx.c @ 49:204718b0fa54
Couple of fixes
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 27 Nov 2009 16:45:32 +0900 |
parents | 2db15632a63d |
children | dbba83bafd66 |
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 */