Changeset 454:f1484823cb4a in freeDiameter
- Timestamp:
- Jul 29, 2010, 4:11:12 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/cnxctx.c
r423 r454 464 464 { 465 465 CHECK_PARAMS_DO( conn, return 0 ); 466 fd_cpu_flush_cache(); 466 467 return conn->cc_status & CC_STATUS_TLS; 467 468 } … … 545 546 546 547 /* Mark the error */ 548 fd_cpu_flush_cache(); 547 549 conn->cc_status |= CC_STATUS_ERROR; 548 550 … … 553 555 conn->cc_status |= CC_STATUS_SIGNALED; 554 556 } 555 557 fd_cpu_flush_cache(); 556 558 return; 557 559 fatal: … … 581 583 /* Handle special case of timeout */ 582 584 if ((ret < 0) && (errno == EAGAIN)) { 585 fd_cpu_flush_cache(); 583 586 if (! (conn->cc_status & CC_STATUS_CLOSING)) 584 587 goto again; /* don't care, just ignore */ … … 607 610 /* Handle special case of timeout */ 608 611 if ((ret < 0) && (errno == EAGAIN)) { 612 fd_cpu_flush_cache(); 609 613 if (! (conn->cc_status & CC_STATUS_CLOSING)) 610 614 goto again; /* don't care, just ignore */ … … 725 729 726 730 do { 731 fd_cpu_flush_cache(); 727 732 CHECK_FCT_DO( fd_sctp_recvmeta(conn->cc_socket, NULL, &buf, &bufsz, &event, &conn->cc_status), goto fatal ); 728 733 if (event == FDEVP_CNX_ERROR) { … … 796 801 switch (ret) { 797 802 case GNUTLS_E_REHANDSHAKE: 803 fd_cpu_flush_cache(); 798 804 if (!(conn->cc_status & CC_STATUS_CLOSING)) 799 805 CHECK_GNUTLS_DO( ret = gnutls_handshake(session), … … 807 813 case GNUTLS_E_AGAIN: 808 814 case GNUTLS_E_INTERRUPTED: 815 fd_cpu_flush_cache(); 809 816 if (!(conn->cc_status & CC_STATUS_CLOSING)) 810 817 goto again; … … 840 847 switch (ret) { 841 848 case GNUTLS_E_REHANDSHAKE: 849 fd_cpu_flush_cache(); 842 850 if (!(conn->cc_status & CC_STATUS_CLOSING)) 843 851 CHECK_GNUTLS_DO( ret = gnutls_handshake(session), … … 851 859 case GNUTLS_E_AGAIN: 852 860 case GNUTLS_E_INTERRUPTED: 861 fd_cpu_flush_cache(); 853 862 if (!(conn->cc_status & CC_STATUS_CLOSING)) 854 863 goto again; … … 1235 1244 1236 1245 /* Mark the connection as protected from here, so that the gnutls credentials will be freed */ 1246 fd_cpu_flush_cache(); 1237 1247 conn->cc_status |= CC_STATUS_TLS; 1238 1248 … … 1359 1369 TRACE_ENTRY("%p %p %zd", conn, buf, len); 1360 1370 do { 1371 fd_cpu_flush_cache(); 1361 1372 if (conn->cc_status & CC_STATUS_TLS) { 1362 1373 CHECK_GNUTLS_DO( ret = fd_tls_send_handle_error(conn, conn->cc_tls_para.session, buf + sent, len - sent), ); … … 1392 1403 /* Send the buffer over all other streams */ 1393 1404 uint16_t str; 1405 fd_cpu_flush_cache(); 1394 1406 if (conn->cc_status & CC_STATUS_TLS) { 1395 1407 for ( str=1; str < conn->cc_sctp_para.pairs; str++) { … … 1474 1486 CHECK_PARAMS_DO(conn, return); 1475 1487 1488 fd_cpu_flush_cache(); 1476 1489 conn->cc_status |= CC_STATUS_CLOSING; 1477 1490 -
freeDiameter/p_ce.c
r403 r454 613 613 614 614 /* Are we doing an election ? */ 615 fd_cpu_flush_cache(); 615 616 if (peer->p_hdr.info.runtime.pir_state == STATE_WAITCNXACK_ELEC) { 616 617 if (election_result(peer)) { … … 661 662 662 663 /* If the state is not WAITCEA, just discard the message */ 664 fd_cpu_flush_cache(); 663 665 if (req || (peer->p_hdr.info.runtime.pir_state != STATE_WAITCEA)) { 664 666 if (*msg) { … … 922 924 int fd_p_ce_handle_newCER(struct msg ** msg, struct fd_peer * peer, struct cnxctx ** cnx, int valid) 923 925 { 926 fd_cpu_flush_cache(); 924 927 switch (peer->p_hdr.info.runtime.pir_state) { 925 928 case STATE_CLOSED: -
freeDiameter/p_dp.c
r403 r454 114 114 } else { 115 115 /* We received a DPA */ 116 fd_cpu_flush_cache(); 116 117 if (peer->p_hdr.info.runtime.pir_state != STATE_CLOSING) { 117 118 TRACE_DEBUG(INFO, "Ignoring DPA received in state %s", STATE_STR(peer->p_hdr.info.runtime.pir_state)); -
freeDiameter/p_dw.c
r258 r454 123 123 124 124 /* If we are in REOPEN state, increment the counter */ 125 fd_cpu_flush_cache(); 125 126 if (peer->p_hdr.info.runtime.pir_state == STATE_REOPEN) { 126 127 peer->p_flags.pf_reopen_cnt += 1; -
freeDiameter/p_expiry.c
r78 r454 61 61 struct fd_peer * peer = (struct fd_peer *)li; 62 62 63 fd_cpu_flush_cache(); 63 64 if (peer->p_hdr.info.runtime.pir_state != STATE_ZOMBIE) 64 65 continue; -
freeDiameter/p_out.c
r258 r454 143 143 CHECK_PARAMS( msg && *msg && (cnx || (peer && peer->p_cnxctx))); 144 144 145 fd_cpu_flush_cache(); 145 146 if (peer && (peer->p_hdr.info.runtime.pir_state == STATE_OPEN)) { 146 147 /* Normal case: just queue for the out thread to pick it up */ -
freeDiameter/p_psm.c
r403 r454 184 184 TRACE_ENTRY("%p %d(%s)", peer, new_state, STATE_STR(new_state)); 185 185 CHECK_PARAMS( CHECK_PEER(peer) ); 186 fd_cpu_flush_cache(); 186 187 old = peer->p_hdr.info.runtime.pir_state; 187 188 if (old == new_state) … … 194 195 195 196 peer->p_hdr.info.runtime.pir_state = new_state; 197 fd_cpu_flush_cache(); 196 198 197 199 if (old == STATE_OPEN) { … … 251 253 { 252 254 /* Move to CLOSED state: failover messages, stop OUT thread, unlink peer from active list */ 255 fd_cpu_flush_cache(); 253 256 if (peer->p_hdr.info.runtime.pir_state != STATE_ZOMBIE) { 254 257 CHECK_FCT_DO( fd_psm_change_state(peer, STATE_CLOSED), /* continue */ ); … … 281 284 CHECK_PARAMS_DO( CHECK_PEER(peer), return ); 282 285 peer->p_hdr.info.runtime.pir_state = STATE_ZOMBIE; 286 fd_cpu_flush_cache(); 283 287 return; 284 288 } … … 306 310 /* The state machine starts in CLOSED state */ 307 311 peer->p_hdr.info.runtime.pir_state = STATE_CLOSED; 308 312 309 313 /* Wait that the PSM are authorized to start in the daemon */ 310 314 CHECK_FCT_DO( fd_psm_waitstart(), goto psm_end ); … … 709 713 peer->p_hdr.info.pi_diamid); 710 714 pthread_cleanup_pop(1); /* set STATE_ZOMBIE */ 715 fd_cpu_flush_cache(); 711 716 peer->p_psm = (pthread_t)NULL; 712 717 pthread_detach(pthread_self()); … … 742 747 CHECK_PARAMS( CHECK_PEER(peer) ); 743 748 749 fd_cpu_flush_cache(); 744 750 if (peer->p_hdr.info.runtime.pir_state != STATE_ZOMBIE) { 745 751 CHECK_FCT( fd_event_send(peer->p_events, FDEVP_TERMINATE, 0, reason) ); -
freeDiameter/peers.c
r403 r454 279 279 struct fd_peer * peer = (struct fd_peer *)li; 280 280 281 fd_cpu_flush_cache(); 281 282 if (peer->p_hdr.info.runtime.pir_state != STATE_ZOMBIE) { 282 283 CHECK_FCT_DO( fd_psm_terminate(peer, "REBOOTING"), /* continue */ ); … … 306 307 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { 307 308 struct fd_peer * peer = (struct fd_peer *)li; 309 fd_cpu_flush_cache(); 308 310 if (peer->p_hdr.info.runtime.pir_state == STATE_ZOMBIE) { 309 311 li = li->prev; /* to avoid breaking the loop */ … … 462 464 } else { 463 465 /* Check if the peer is in zombie state */ 466 fd_cpu_flush_cache(); 464 467 if (peer->p_hdr.info.runtime.pir_state == STATE_ZOMBIE) { 465 468 /* Re-activate the peer */ -
freeDiameter/routing_dispatch.c
r403 r454 815 815 /* Find the peer corresponding to this name */ 816 816 CHECK_FCT( fd_peer_getbyid( qry_src, (void *) &peer ) ); 817 fd_cpu_flush_cache(); 817 818 if ((!peer) || (peer->p_hdr.info.runtime.pir_state != STATE_OPEN)) { 818 819 TRACE_DEBUG(INFO, "Unable to forward answer message to peer '%s', deleted or not in OPEN state.", qry_src); … … 934 935 CHECK_FCT( fd_peer_getbyid( c->diamid, (void *)&peer ) ); 935 936 937 fd_cpu_flush_cache(); 936 938 if (peer && (peer->p_hdr.info.runtime.pir_state == STATE_OPEN)) { 937 939 /* Send to this one */ -
freeDiameter/sctps.c
r403 r454 87 87 88 88 do { 89 fd_cpu_flush_cache(); 89 90 CHECK_FCT_DO( fd_sctp_recvmeta(conn->cc_socket, &strid, &buf, &bufsz, &event, &conn->cc_status), goto fatal ); 90 91 switch (event) { … … 171 172 CHECK_PARAMS_DO( tr && data, { errno = EINVAL; return -1; } ); 172 173 174 fd_cpu_flush_cache(); 173 175 CHECK_FCT_DO( fd_sctp_sendstr(ctx->parent->cc_socket, ctx->strid, (uint8_t *)data, len, &ctx->parent->cc_status), /* errno is already set */ return -1 ); 174 176 … … 620 622 /* End all TLS sessions, in series (not as efficient as paralel, but simpler) */ 621 623 for (i = 1; i < conn->cc_sctp_para.pairs; i++) { 624 fd_cpu_flush_cache(); 622 625 if ( ! (conn->cc_status & CC_STATUS_ERROR)) { 623 626 CHECK_GNUTLS_DO( gnutls_bye(conn->cc_sctps_data.array[i].session, GNUTLS_SHUT_WR), fd_cnx_markerror(conn) ); -
include/freeDiameter/freeDiameter.h
r447 r454 228 228 struct { 229 229 230 enum peer_state pir_state; /* Current state of the peer in the state machine */230 enum peer_state pir_state; /* Current state of the peer in the state machine. fd_cpu_flush_cache() might be useful before reading. */ 231 231 232 232 char * pir_realm; /* The received realm in CER/CEA. */ … … 252 252 struct fd_list pi_endpoints; /* Endpoint(s) of the remote peer (configured, discovered, or advertized). list of struct fd_endpoint. DNS resolved if empty. */ 253 253 }; 254 254 255 255 256 struct peer_hdr { -
include/freeDiameter/libfreeDiameter.h
r453 r454 569 569 } 570 570 571 /* Force flushing the cache of a CPU before reading a shared memory area (use only for atomic reads such as int and void*) */ 572 extern pthread_mutex_t fd_cpu_mtx_dummy; /* only for the macro bellow, so that we have reasonably fresh pir_state value when needed */ 573 #define fd_cpu_flush_cache() { \ 574 (void)pthread_mutex_lock(&fd_cpu_mtx_dummy); \ 575 (void)pthread_mutex_unlock(&fd_cpu_mtx_dummy); \ 576 } 577 578 571 579 /************* 572 580 Cancelation cleanup handlers for common objects -
libfreeDiameter/init.c
r258 r454 36 36 #include "libfD.h" 37 37 38 /* Only for CPU cache flush */ 39 pthread_mutex_t fd_cpu_mtx_dummy = PTHREAD_MUTEX_INITIALIZER; 40 38 41 /* Initialize library variables and threads */ 39 42 int fd_lib_init(int support_signals)
Note: See TracChangeset
for help on using the changeset viewer.