Changeset 691:78b665400097 in freeDiameter for libfdcore
- Timestamp:
- Jan 20, 2011, 7:44:27 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdcore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/core.c
r689 r691 241 241 int fd_core_waitstartcomplete(void) 242 242 { 243 int ret = 0; 244 243 245 TRACE_ENTRY(""); 244 246 … … 246 248 pthread_cleanup_push( fd_cleanup_mutex, &is_ready_mtx ); 247 249 248 while (! is_ready) {249 CHECK_POSIX ( pthread_cond_wait( &is_ready_cnd, &is_ready_mtx ));250 while (!ret && !is_ready) { 251 CHECK_POSIX_DO( ret = pthread_cond_wait( &is_ready_cnd, &is_ready_mtx ), ); 250 252 } 251 253 … … 253 255 CHECK_POSIX( pthread_mutex_unlock( &is_ready_mtx ) ); 254 256 255 return 0;257 return ret; 256 258 } 257 259 -
libfdcore/p_cnx.c
r662 r691 211 211 struct next_conn * nc = NULL; 212 212 int rebuilt = 0; 213 int fatal_error=0; 213 214 214 215 TRACE_ENTRY("%p", arg); … … 226 227 if (FD_IS_LIST_EMPTY(&peer->p_connparams)) { 227 228 if (! rebuilt) { 228 CHECK_FCT_DO( prepare_connection_list(peer), goto fatal_error);229 CHECK_FCT_DO( fatal_error = prepare_connection_list(peer), goto out ); 229 230 rebuilt ++; 230 231 } … … 232 233 /* We encountered an error or we have looped over all the addresses of the peer. */ 233 234 TRACE_DEBUG(INFO, "Unable to connect to the peer %s, aborting attempts for now.", peer->p_hdr.info.pi_diamid); 234 CHECK_FCT_DO( f d_event_send(peer->p_events, FDEVP_CNX_FAILED, 0, NULL), goto fatal_error);235 CHECK_FCT_DO( fatal_error = fd_event_send(peer->p_events, FDEVP_CNX_FAILED, 0, NULL), goto out ); 235 236 return NULL; 236 237 } … … 277 278 empty_connection_list(peer); 278 279 fd_ep_filter(&peer->p_hdr.info.pi_endpoints, EP_FL_CONF); 279 return NULL;280 goto out_pop; 280 281 } ); 281 282 } else { 282 283 /* Prepare to receive the next message */ 283 CHECK_FCT_DO( f d_cnx_start_clear(cnx, 0), goto fatal_error);284 CHECK_FCT_DO( fatal_error = fd_cnx_start_clear(cnx, 0), goto out_pop ); 284 285 } 285 286 286 287 /* Upon success, generate FDEVP_CNX_ESTABLISHED */ 287 CHECK_FCT_DO( fd_event_send(peer->p_events, FDEVP_CNX_ESTABLISHED, 0, cnx), goto fatal_error ); 288 288 CHECK_FCT_DO( fatal_error = fd_event_send(peer->p_events, FDEVP_CNX_ESTABLISHED, 0, cnx), ); 289 out_pop: 290 ; 289 291 pthread_cleanup_pop(0); 290 292 291 return NULL; 292 293 fatal_error: 294 /* Cleanup the connection */ 295 if (cnx) 296 fd_cnx_destroy(cnx); 297 298 /* Generate a termination event */ 299 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), ); 293 out: 294 295 if (fatal_error) { 296 297 /* Cleanup the connection */ 298 if (cnx) 299 fd_cnx_destroy(cnx); 300 301 /* Generate a termination event */ 302 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), ); 303 } 300 304 301 305 return NULL; -
libfdcore/p_expiry.c
r686 r691 98 98 TRACE_ENTRY( "%p", arg ); 99 99 100 CHECK_POSIX_DO( pthread_mutex_lock(&exp_mtx), goto error);100 CHECK_POSIX_DO( pthread_mutex_lock(&exp_mtx), { ASSERT(0); } ); 101 101 pthread_cleanup_push( fd_cleanup_mutex, &exp_mtx ); 102 102 … … 108 108 if (FD_IS_LIST_EMPTY(&exp_list)) { 109 109 /* Just wait for a change or cancelation */ 110 CHECK_POSIX_DO( pthread_cond_wait( &exp_cnd, &exp_mtx ), goto error);110 CHECK_POSIX_DO( pthread_cond_wait( &exp_cnd, &exp_mtx ), { ASSERT(0); } ); 111 111 /* Restart the loop on wakeup */ 112 112 continue; … … 118 118 119 119 /* Get the current time */ 120 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), goto error);120 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), { ASSERT(0); } ); 121 121 122 122 /* If first peer is not expired, we just wait until it happens */ … … 125 125 CHECK_POSIX_DO2( pthread_cond_timedwait( &exp_cnd, &exp_mtx, &first->p_exp_timer ), 126 126 ETIMEDOUT, /* ETIMEDOUT is a normal return value, continue */, 127 /* on other error, */ goto error);127 /* on other error, */ { ASSERT(0); } ); 128 128 129 129 /* on wakeup, loop */ … … 133 133 /* Now, the first peer in the list is expired; signal it */ 134 134 fd_list_unlink( &first->p_expiry ); 135 CHECK_FCT_DO( fd_event_send(first->p_events, FDEVP_TERMINATE, 0, "DO_NOT_WANT_TO_TALK_TO_YOU"), goto error);135 CHECK_FCT_DO( fd_event_send(first->p_events, FDEVP_TERMINATE, 0, "DO_NOT_WANT_TO_TALK_TO_YOU"), break ); 136 136 137 137 } while (1); 138 138 139 139 pthread_cleanup_pop( 1 ); 140 error: 140 141 141 TRACE_DEBUG(INFO, "An error occurred in peers module! Expiry thread is terminating..."); 142 ASSERT(0);143 142 CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), ); 144 143 return NULL; -
libfdcore/p_out.c
r688 r691 69 69 /* Save a request before sending so that there is no race condition with the answer */ 70 70 if (msg_is_a_req) { 71 CHECK_FCT_DO( ret = fd_p_sr_store(srl, msg, &hdr->msg_hbhid, bkp_hbh), { free(buf); return ret; });71 CHECK_FCT_DO( ret = fd_p_sr_store(srl, msg, &hdr->msg_hbhid, bkp_hbh), goto out ); 72 72 } 73 73 74 74 /* Send the message */ 75 CHECK_FCT_DO( ret = fd_cnx_send(cnx, buf, sz, flags), { free(buf); return ret; } ); 75 CHECK_FCT_DO( ret = fd_cnx_send(cnx, buf, sz, flags), ); 76 out: 77 ; 76 78 pthread_cleanup_pop(1); 79 80 if (ret) 81 return ret; 77 82 78 83 /* Free remaining messages (i.e. answers) */ -
libfdcore/p_psm.c
r688 r691 55 55 static int fd_psm_waitstart() 56 56 { 57 int ret = 0; 57 58 TRACE_ENTRY(""); 58 59 CHECK_POSIX( pthread_mutex_lock(&started_mtx) ); 59 60 awake: 60 if (! 61 if (!ret && !started) { 61 62 pthread_cleanup_push( fd_cleanup_mutex, &started_mtx ); 62 CHECK_POSIX ( pthread_cond_wait(&started_cnd, &started_mtx));63 CHECK_POSIX_DO( ret = pthread_cond_wait(&started_cnd, &started_mtx), ); 63 64 pthread_cleanup_pop( 0 ); 64 65 goto awake; 65 66 } 66 67 CHECK_POSIX( pthread_mutex_unlock(&started_mtx) ); 67 return 0;68 return ret; 68 69 } 69 70 -
libfdcore/p_sr.c
r688 r691 117 117 } 118 118 119 /* thread that handles messages expiring. The thread is started / stopped only when needed */119 /* thread that handles messages expiring. The thread is started / cancelled only when needed */ 120 120 static void * sr_expiry_th(void * arg) { 121 121 struct sr_list * srlist = arg; … … 184 184 ; /* pthread_cleanup_pop sometimes expands as "} ..." and the label beofre this cause some compilers to complain... */ 185 185 pthread_cleanup_pop( 1 ); 186 ASSERT(0); /* we have encountered a problem, maybe time to signal the framework to terminate? */ 186 187 return NULL; 187 188 } -
libfdcore/peers.c
r688 r691 533 533 int auth = 0; 534 534 pthread_cleanup_push(fd_cleanup_rwlock, &validators_rw); 535 CHECK_FCT_DO( ret = ((int(*)(struct peer_info *, int *, int (**)(struct peer_info *)))(v->o)) (&peer->p_hdr.info, &auth, &peer->p_cb2), goto out);535 CHECK_FCT_DO( ret = ((int(*)(struct peer_info *, int *, int (**)(struct peer_info *)))(v->o)) (&peer->p_hdr.info, &auth, &peer->p_cb2), ); 536 536 pthread_cleanup_pop(0); 537 if (ret) 538 goto out; 537 539 if (auth) { 538 540 ret = (auth > 0) ? 0 : -1; -
libfdcore/routing_dispatch.c
r688 r691 1000 1000 { 1001 1001 int must_stop; 1002 CHECK_POSIX_DO( pthread_mutex_lock(&order_lock), goto end); /* we lock to flush the caches */1002 CHECK_POSIX_DO( pthread_mutex_lock(&order_lock), { ASSERT(0); } ); /* we lock to flush the caches */ 1003 1003 must_stop = (order_val == STOP); 1004 CHECK_POSIX_DO( pthread_mutex_unlock(&order_lock), goto end);1004 CHECK_POSIX_DO( pthread_mutex_unlock(&order_lock), { ASSERT(0); } ); 1005 1005 if (must_stop) 1006 1006 goto end; -
libfdcore/sctp.c
r662 r691 822 822 823 823 /* Set the socket options */ 824 CHECK_FCT_DO( ret = fd_setsockopt_prebind(*sock), goto fail);824 CHECK_FCT_DO( ret = fd_setsockopt_prebind(*sock), goto out ); 825 825 826 826 /* Create the array of addresses, add first the configured addresses, then the discovered, then the other ones */ 827 CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF, EP_FL_CONF ), goto fail);828 CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF | EP_FL_DISC, EP_FL_DISC ), goto fail);829 CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF | EP_FL_DISC, 0 ), goto fail);827 CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF, EP_FL_CONF ), goto out ); 828 CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF | EP_FL_DISC, EP_FL_DISC ), goto out ); 829 CHECK_FCT_DO( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htons(port), list, EP_FL_CONF | EP_FL_DISC, 0 ), goto out ); 830 830 831 831 /* Try connecting */ … … 866 866 /* Some errors are expected, we log at different level */ 867 867 TRACE_DEBUG( lvl, "sctp_connectx returned an error: %s", strerror(ret)); 868 goto fail;868 goto out; 869 869 } 870 870 … … 872 872 873 873 /* Set the remaining sockopts */ 874 CHECK_FCT_DO( ret = fd_setsockopt_postbind(*sock, 1), goto fail_deco ); 875 876 /* Done! */ 874 CHECK_FCT_DO( ret = fd_setsockopt_postbind(*sock, 1), 875 { 876 CHECK_SYS_DO( shutdown(*sock, SHUT_RDWR), /* continue */ ); 877 } ); 878 879 out: 880 ; 877 881 pthread_cleanup_pop(0); 878 return 0; 879 880 fail_deco: 881 CHECK_SYS_DO( shutdown(*sock, SHUT_RDWR), /* continue */ ); 882 fail: 883 if (*sock > 0) { 884 CHECK_SYS_DO( close(*sock), /* continue */ ); 885 *sock = -1; 886 } 887 free(sar.buf); 882 883 if (ret) { 884 if (*sock > 0) { 885 CHECK_SYS_DO( close(*sock), /* continue */ ); 886 *sock = -1; 887 } 888 free(sar.buf); 889 } 888 890 return ret; 889 891 } -
libfdcore/server.c
r688 r691 151 151 pthread_cleanup_push((void *)fd_cnx_destroy, c->conn); 152 152 pthread_cleanup_push((void *)fd_msg_free, msg); 153 CHECK_FCT_DO( fd_peer_handle_newCER( &msg, &c->conn ), goto cleanup);153 CHECK_FCT_DO( fd_peer_handle_newCER( &msg, &c->conn ), ); 154 154 pthread_cleanup_pop(0); 155 155 pthread_cleanup_pop(0); -
libfdcore/tcp.c
r662 r691 134 134 CHECK_SYS( s = socket(sa->sa_family, SOCK_STREAM, IPPROTO_TCP) ); 135 135 136 /* Set the socket options */ 137 CHECK_FCT( fd_tcp_setsockopt(sa->sa_family, s) ); 138 136 139 /* Cleanup if we are cancelled */ 137 140 pthread_cleanup_push(fd_cleanup_socket, &s); 138 139 /* Set the socket options */140 CHECK_FCT( fd_tcp_setsockopt(sa->sa_family, s) );141 141 142 142 TRACE_DEBUG_sSA(FULL, "Attempting TCP connection with peer: ", sa, NI_NUMERICHOST | NI_NUMERICSERV, "..." );
Note: See TracChangeset
for help on using the changeset viewer.