diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-04-05 20:54:12 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-04-05 20:54:12 +0000 |
commit | dca11c9bba5efded6accca9730cc6c67c9dc03fd (patch) | |
tree | 5feb089c9efb9ddb55eff91f349d24b0942e883c /TAO/tao/Wait_On_Leader_Follower.cpp | |
parent | 5ad56ccfe54e3567088b081d044dcb45e7816e20 (diff) | |
download | ATCD-dca11c9bba5efded6accca9730cc6c67c9dc03fd.tar.gz |
ChangeLogTag: Thu Apr 5 13:50:00 2001 Michael Kircher <Michael.Kircher@mchp.siemens.de>
Diffstat (limited to 'TAO/tao/Wait_On_Leader_Follower.cpp')
-rw-r--r-- | TAO/tao/Wait_On_Leader_Follower.cpp | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/TAO/tao/Wait_On_Leader_Follower.cpp b/TAO/tao/Wait_On_Leader_Follower.cpp index 089c4b605f2..39f3a3e9e9f 100644 --- a/TAO/tao/Wait_On_Leader_Follower.cpp +++ b/TAO/tao/Wait_On_Leader_Follower.cpp @@ -132,6 +132,9 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time, ACE_TEXT ("TAO (%P|%t) - wait (follower) on <%x> ") ACE_TEXT ("cond == 0 || cond->wait () == -1 : cond = %d\n"), this->transport_, (cond == 0) ? 0 : cond)); + + // @@ Michael: What is our error handling in this case? + // We could be elected as leader and no leader would come in? return -1; } } @@ -148,11 +151,33 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time, ACE_TEXT ("cond == 0 || cond->wait (tv) == -1\n"), this->transport_)); - if (leader_follower.remove_follower (&node) == -1) - ACE_ERROR ((LM_ERROR, - "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - " - "remove_follower failed for <%x>\n", node.follower_)); - + if (leader_follower.remove_follower (&node) == -1 + && reply_received == 0) + { + // Remove follower can fail because either + // 1) the reply arrived, or + // 2) somebody elected us as leader, or + // 3) the connection got closed. + // + // reply_received is 1, if the reply arrived. + // reply_received is 0, if the reply did not arrive yet. + // reply_received is -1, if the connection got closed + // + // Therefore: + // If remove_follower fails and reply_received is 0, we know that + // we got elected as a leader. As we cannot be the leader (remember + // we got a timeout), we have to select a new leader. + // + // ACE_DEBUG ((LM_DEBUG, + // "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - " + // "We got elected as leader, but have timeout\n")); + + if (leader_follower.elect_new_leader () == -1) + ACE_ERROR ((LM_ERROR, + "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - " + "elect_new_leader failed\n")); + + } return -1; } } @@ -160,15 +185,11 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time, countdown.update (); -#if 0 - // Cannot remove the follower here, we *must* remove it when + // @@ Michael: This is an old comment why we do not want to + // remove the follower here. + // We should not remove the follower here, we *must* remove it when // we signal it so the same condition is not signalled for // both wake up as a follower and as the next leader. - if (leader_follower.remove_follower (&node) == -1) - ACE_ERROR ((LM_ERROR, - "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - " - "remove_follower failed for <%x>\n", node.follower)); -#endif /* 0 */ if (TAO_debug_level >= 5) ACE_DEBUG ((LM_DEBUG, |