Mercurial > hg > freeDiameter
comparison freeDiameter/p_psm.c @ 38:68c1890f7049
Fixed a small bug in SCTP close
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 05 Nov 2009 17:29:12 +0900 |
parents | cc3c59fe98fe |
children | 7e1deaa89540 |
comparison
equal
deleted
inserted
replaced
37:cc3c59fe98fe | 38:68c1890f7049 |
---|---|
240 peer->p_psm_timer.tv_sec += 10; | 240 peer->p_psm_timer.tv_sec += 10; |
241 #endif | 241 #endif |
242 } | 242 } |
243 | 243 |
244 /* Cleanup the peer */ | 244 /* Cleanup the peer */ |
245 void fd_psm_cleanup(struct fd_peer * peer) | 245 void fd_psm_cleanup(struct fd_peer * peer, int terminate) |
246 { | 246 { |
247 /* Move to CLOSED state: failover messages, stop OUT thread, unlink peer from active list */ | 247 /* Move to CLOSED state: failover messages, stop OUT thread, unlink peer from active list */ |
248 CHECK_FCT_DO( fd_psm_change_state(peer, STATE_CLOSED), /* continue */ ); | 248 CHECK_FCT_DO( fd_psm_change_state(peer, STATE_CLOSED), /* continue */ ); |
249 | 249 |
250 /* Destroy data */ | 250 |
251 CHECK_FCT_DO( fd_thr_term(&peer->p_ini_thr), /* continue */); | 251 fd_p_cnx_abort(peer, terminate); |
252 | |
252 if (peer->p_cnxctx) { | 253 if (peer->p_cnxctx) { |
253 fd_cnx_destroy(peer->p_cnxctx); | 254 fd_cnx_destroy(peer->p_cnxctx); |
254 peer->p_cnxctx = NULL; | 255 peer->p_cnxctx = NULL; |
255 } | 256 } |
257 | |
256 if (peer->p_initiator) { | 258 if (peer->p_initiator) { |
257 fd_cnx_destroy(peer->p_initiator); | 259 fd_cnx_destroy(peer->p_initiator); |
258 peer->p_initiator = NULL; | 260 peer->p_initiator = NULL; |
259 } | 261 } |
262 | |
260 if (peer->p_receiver) { | 263 if (peer->p_receiver) { |
261 fd_cnx_destroy(peer->p_receiver); | 264 fd_cnx_destroy(peer->p_receiver); |
262 peer->p_receiver = NULL; | 265 peer->p_receiver = NULL; |
266 } | |
267 | |
268 if (terminate) { | |
269 CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ ); | |
263 } | 270 } |
264 | 271 |
265 } | 272 } |
266 | 273 |
267 | 274 |
524 /* Mark the connection problem */ | 531 /* Mark the connection problem */ |
525 peer->p_flags.pf_cnx_pb = 1; | 532 peer->p_flags.pf_cnx_pb = 1; |
526 | 533 |
527 case STATE_CLOSING: | 534 case STATE_CLOSING: |
528 /* Cleanup the peer */ | 535 /* Cleanup the peer */ |
529 fd_psm_cleanup(peer); | 536 fd_psm_cleanup(peer, 0); |
530 | 537 |
531 /* Reset the timer */ | 538 /* Reset the timer */ |
532 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc); | 539 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc); |
533 | 540 |
534 case STATE_CLOSED: | 541 case STATE_CLOSED: |
599 case STATE_CLOSING: | 606 case STATE_CLOSING: |
600 case STATE_SUSPECT: | 607 case STATE_SUSPECT: |
601 case STATE_WAITCNXACK: | 608 case STATE_WAITCNXACK: |
602 case STATE_WAITCEA: | 609 case STATE_WAITCEA: |
603 /* Destroy the connection, restart the timer to a new connection attempt */ | 610 /* Destroy the connection, restart the timer to a new connection attempt */ |
604 fd_psm_cleanup(peer); | 611 fd_psm_cleanup(peer, 0); |
605 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc); | 612 fd_psm_next_timeout(peer, 1, peer->p_hdr.info.config.pic_tctimer ?: fd_g_config->cnf_timer_tc); |
606 break; | 613 break; |
607 | 614 |
608 case STATE_WAITCNXACK_ELEC: | 615 case STATE_WAITCNXACK_ELEC: |
609 TODO("Abort initiating side, handle the receiver side"); | 616 TODO("Abort initiating side, handle the receiver side"); |
619 } | 626 } |
620 | 627 |
621 goto psm_loop; | 628 goto psm_loop; |
622 | 629 |
623 psm_end: | 630 psm_end: |
624 fd_psm_cleanup(peer); | 631 fd_psm_cleanup(peer, 1); |
625 CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ ); | |
626 pthread_cleanup_pop(1); /* set STATE_ZOMBIE */ | 632 pthread_cleanup_pop(1); /* set STATE_ZOMBIE */ |
627 peer->p_psm = (pthread_t)NULL; | 633 peer->p_psm = (pthread_t)NULL; |
628 pthread_detach(pthread_self()); | 634 pthread_detach(pthread_self()); |
629 return NULL; | 635 return NULL; |
630 } | 636 } |
672 | 678 |
673 /* Cancel PSM thread */ | 679 /* Cancel PSM thread */ |
674 CHECK_FCT_DO( fd_thr_term(&peer->p_psm), /* continue */ ); | 680 CHECK_FCT_DO( fd_thr_term(&peer->p_psm), /* continue */ ); |
675 | 681 |
676 /* Cleanup the data */ | 682 /* Cleanup the data */ |
677 fd_psm_cleanup(peer); | 683 fd_psm_cleanup(peer, 1); |
678 | 684 |
679 /* Destroy the event list */ | 685 /* Destroy the event list */ |
680 CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ ); | 686 CHECK_FCT_DO( fd_fifo_del(&peer->p_events), /* continue */ ); |
681 | 687 |
682 /* Remaining cleanups are performed in fd_peer_free */ | 688 /* Remaining cleanups are performed in fd_peer_free */ |