Mercurial > hg > freeDiameter
comparison freeDiameter/peers.c @ 454:f1484823cb4a
Small hack which might spear some concurrency problems and is quite harmless
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 29 Jul 2010 16:11:12 +0900 |
parents | 26aafbbc1640 |
children | 5e5d8152c229 |
comparison
equal
deleted
inserted
replaced
453:9a8b3178a7a7 | 454:f1484823cb4a |
---|---|
276 | 276 |
277 CHECK_FCT_DO( pthread_rwlock_wrlock(&fd_g_peers_rw), /* continue */ ); | 277 CHECK_FCT_DO( pthread_rwlock_wrlock(&fd_g_peers_rw), /* continue */ ); |
278 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { | 278 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { |
279 struct fd_peer * peer = (struct fd_peer *)li; | 279 struct fd_peer * peer = (struct fd_peer *)li; |
280 | 280 |
281 fd_cpu_flush_cache(); | |
281 if (peer->p_hdr.info.runtime.pir_state != STATE_ZOMBIE) { | 282 if (peer->p_hdr.info.runtime.pir_state != STATE_ZOMBIE) { |
282 CHECK_FCT_DO( fd_psm_terminate(peer, "REBOOTING"), /* continue */ ); | 283 CHECK_FCT_DO( fd_psm_terminate(peer, "REBOOTING"), /* continue */ ); |
283 } else { | 284 } else { |
284 li = li->prev; /* to avoid breaking the loop */ | 285 li = li->prev; /* to avoid breaking the loop */ |
285 fd_list_unlink(&peer->p_hdr.chain); | 286 fd_list_unlink(&peer->p_hdr.chain); |
303 | 304 |
304 /* Remove zombie peers */ | 305 /* Remove zombie peers */ |
305 CHECK_FCT_DO( pthread_rwlock_wrlock(&fd_g_peers_rw), /* continue */ ); | 306 CHECK_FCT_DO( pthread_rwlock_wrlock(&fd_g_peers_rw), /* continue */ ); |
306 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { | 307 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { |
307 struct fd_peer * peer = (struct fd_peer *)li; | 308 struct fd_peer * peer = (struct fd_peer *)li; |
309 fd_cpu_flush_cache(); | |
308 if (peer->p_hdr.info.runtime.pir_state == STATE_ZOMBIE) { | 310 if (peer->p_hdr.info.runtime.pir_state == STATE_ZOMBIE) { |
309 li = li->prev; /* to avoid breaking the loop */ | 311 li = li->prev; /* to avoid breaking the loop */ |
310 fd_list_unlink(&peer->p_hdr.chain); | 312 fd_list_unlink(&peer->p_hdr.chain); |
311 fd_list_insert_before(&purge, &peer->p_hdr.chain); | 313 fd_list_insert_before(&purge, &peer->p_hdr.chain); |
312 } | 314 } |
459 | 461 |
460 /* Start the PSM, which will receive the event bellow */ | 462 /* Start the PSM, which will receive the event bellow */ |
461 CHECK_FCT_DO( ret = fd_psm_begin(peer), goto out ); | 463 CHECK_FCT_DO( ret = fd_psm_begin(peer), goto out ); |
462 } else { | 464 } else { |
463 /* Check if the peer is in zombie state */ | 465 /* Check if the peer is in zombie state */ |
466 fd_cpu_flush_cache(); | |
464 if (peer->p_hdr.info.runtime.pir_state == STATE_ZOMBIE) { | 467 if (peer->p_hdr.info.runtime.pir_state == STATE_ZOMBIE) { |
465 /* Re-activate the peer */ | 468 /* Re-activate the peer */ |
466 if (peer->p_hdr.info.config.pic_flags.exp) | 469 if (peer->p_hdr.info.config.pic_flags.exp) |
467 peer->p_flags.pf_responder = 1; | 470 peer->p_flags.pf_responder = 1; |
468 peer->p_hdr.info.runtime.pir_state = STATE_NEW; | 471 peer->p_hdr.info.runtime.pir_state = STATE_NEW; |