summaryrefslogtreecommitdiff
path: root/TAO/tao/Wait_Strategy.cpp
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-14 02:43:31 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-14 02:43:31 +0000
commitf944aba33b0ee5dfa6a26896da04075f1d34e27b (patch)
tree900c7831f5d993c5208ecd9a6de6de8d043b6e6c /TAO/tao/Wait_Strategy.cpp
parentad3c247c630848f94ab179c0bd1ba47a25ea0ede (diff)
downloadATCD-f944aba33b0ee5dfa6a26896da04075f1d34e27b.tar.gz
ChangeLogTag:Tue Jul 13 21:43:30 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Wait_Strategy.cpp')
-rw-r--r--TAO/tao/Wait_Strategy.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/TAO/tao/Wait_Strategy.cpp b/TAO/tao/Wait_Strategy.cpp
index 6fcd47d5026..44cd1feb188 100644
--- a/TAO/tao/Wait_Strategy.cpp
+++ b/TAO/tao/Wait_Strategy.cpp
@@ -142,9 +142,9 @@ TAO_Wait_On_Leader_Follower::sending_request (TAO_ORB_Core *orb_core,
// remember in which thread the client connection handler was running
this->calling_thread_ = ACE_Thread::self ();
- //if (TAO_debug_level > 0)
- //ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - sending request for <%x>\n",
- //this->transport_));
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - sending request for <%x>\n",
+ this->transport_));
}
// Register the handler.
@@ -209,15 +209,22 @@ TAO_Wait_On_Leader_Follower::wait (ACE_Time_Value *max_wait_time)
this->cond_response_available ();
// Add ourselves to the list, do it only once because we can
- // wake up multiple times from the CV loop
- if (leader_follower.add_follower (cond) == -1)
- ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - "
- "add_follower failed for <%x>\n",
- cond));
+ // wake up multiple times from the CV loop. And only do it if
+ // the reply has not been received (it could have arrived while
+ // we were preparing to receive it).
- while (!this->reply_received_ &&
- leader_follower.leader_available ())
+ if (!this->reply_received_
+ && leader_follower.leader_available ())
+ {
+ if (leader_follower.add_follower (cond) == -1)
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - "
+ "add_follower failed for <%x>\n",
+ cond));
+ }
+
+ while (!this->reply_received_
+ && leader_follower.leader_available ())
{
if (max_wait_time == 0)
{
@@ -235,10 +242,15 @@ 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 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 (cond) == -1)
ACE_ERROR ((LM_ERROR,
"TAO (%P|%t) TAO_Wait_On_Leader_Follower::wait - "
"remove_follower failed for <%x>\n", cond));
+#endif /* 0 */
//ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - done (follower:%d) on <%x>\n",
//this->reply_received_, this->transport_));
@@ -458,6 +470,21 @@ TAO_Wait_On_Leader_Follower::wake_up (void)
ACE_SYNCH_CONDITION* cond =
this->cond_response_available ();
+ //if (TAO_debug_level > 0)
+ //ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - wake up follower %x\n",
+ // cond));
+
+ TAO_Leader_Follower& leader_follower =
+ this->transport_->orb_core ()->leader_follower ();
+
+ // 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.
+ // The follower may not be there if the reply is received while the
+ // consumer is not yet waiting for it (i.e. it send the request but
+ // has not blocked to receive the reply yet)
+ (void) leader_follower.remove_follower (cond); // Ignore errors
+
if (cond != 0)
(void) cond->signal ();
}