summaryrefslogtreecommitdiff
path: root/TAO/tao/Leader_Follower.inl
diff options
context:
space:
mode:
authormcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2011-11-02 08:35:59 +0000
committermcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2011-11-02 08:35:59 +0000
commit79b08ad9a985361d2c5bd336c000cbfb71010b12 (patch)
tree76754c2487a78d132935486bb573c94838e2b311 /TAO/tao/Leader_Follower.inl
parentc6ceb1c3b41d8d97662f696f4cc48de3ad7ad00e (diff)
downloadATCD-79b08ad9a985361d2c5bd336c000cbfb71010b12.tar.gz
Wed Nov 02 08:30:13 UTC 2011 Martin Corino <mcorino@remedy.nl>
Merged changes from Remedy work branch.
Diffstat (limited to 'TAO/tao/Leader_Follower.inl')
-rw-r--r--TAO/tao/Leader_Follower.inl23
1 files changed, 20 insertions, 3 deletions
diff --git a/TAO/tao/Leader_Follower.inl b/TAO/tao/Leader_Follower.inl
index 95d3f89fdc1..258c4dda450 100644
--- a/TAO/tao/Leader_Follower.inl
+++ b/TAO/tao/Leader_Follower.inl
@@ -139,6 +139,17 @@ TAO_Leader_Follower::set_upcall_thread (void)
this->elect_new_leader ();
}
+ else if (tss->client_leader_thread_ == 1)
+ { // We are client leader thread going to handle upcall.
+ // When we're only leading one level (which should
+ // now always be the case since we implement leadership
+ // abdication here) we can now give up leadership to allow a
+ // waiting event thread to take over leaderpship
+ ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock ());
+ this->reset_client_leader_thread ();
+
+ this->elect_new_leader ();
+ }
}
ACE_INLINE bool
@@ -160,9 +171,15 @@ ACE_INLINE void
TAO_Leader_Follower::reset_client_leader_thread (void)
{
TAO_ORB_Core_TSS_Resources *tss = this->get_tss_resources ();
- --tss->client_leader_thread_;
- --this->leaders_;
- --this->client_thread_is_leader_;
+ // We may be called twice when we gave up leadership from
+ // set_upcall_thread () if so tss->client_leader_thread_ may
+ // already have been decremented to 0
+ if (tss->client_leader_thread_ > 0)
+ {
+ --tss->client_leader_thread_;
+ --this->leaders_;
+ --this->client_thread_is_leader_;
+ }
}
ACE_INLINE bool