summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp')
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp171
1 files changed, 128 insertions, 43 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
index e93571dcb0d..cd226dd123c 100644
--- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp
@@ -149,13 +149,25 @@ LiveEntry::reset_status (void)
this->repings_ = 0;
this->next_check_ = ACE_High_Res_Timer::gettimeofday_hr();
}
+ if (ImR_Locator_i::debug () > 2)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) LiveEntry::reset_status this = %x, ")
+ ACE_TEXT ("server = %C status = %s\n"),
+ this, this->server_.c_str(),
+ status_name (this->liveliness_)));
+ }
+
}
LiveStatus
LiveEntry::status (void) const
{
if (!this->may_ping_)
- return LS_ALIVE;
+ {
+ return LS_ALIVE;
+ }
+
if ( this->liveliness_ == LS_ALIVE &&
this->owner_->ping_interval() != ACE_Time_Value::zero )
@@ -243,7 +255,7 @@ LiveEntry::validate_ping (bool &want_reping, ACE_Time_Value& next)
this->liveliness_ == LS_DEAD ||
this->listeners_.size () == 0)
{
- if (ImR_Locator_i::debug () > 5)
+ if (ImR_Locator_i::debug () > 4)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, status ")
@@ -300,6 +312,14 @@ LiveEntry::validate_ping (bool &want_reping, ACE_Time_Value& next)
}
ACE_Time_Value next (ms / 1000, (ms % 1000) * 1000);
this->next_check_ = now + next;
+ if (ImR_Locator_i::debug () > 4)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, ")
+ ACE_TEXT ("transient, reping in %d ms, ")
+ ACE_TEXT ("server %C\n"),
+ ms, this->server_.c_str()));
+ }
}
else
{
@@ -337,6 +357,10 @@ LiveEntry::do_ping (PortableServer::POA_ptr poa)
CORBA::Object_var obj = poa->id_to_reference (oid.in());
ImplementationRepository::AMI_ServerObjectHandler_var cb =
ImplementationRepository::AMI_ServerObjectHandler::_narrow (obj.in());
+ {
+ ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
+ this->liveliness_ = LS_PING_AWAY;
+ }
try
{
this->ref_->sendc_ping (cb.in());
@@ -346,8 +370,6 @@ LiveEntry::do_ping (PortableServer::POA_ptr poa)
ACE_TEXT ("(%P|%t) LiveEntry::do_ping, ")
ACE_TEXT ("sendc_ping returned OK\n")));
}
- ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
- this->liveliness_ = LS_PING_AWAY;
}
catch (CORBA::Exception &ex)
{
@@ -422,10 +444,74 @@ PingReceiver::ping_excep (Messaging::ExceptionHolder * excep_holder)
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
+LC_TimeoutGuard::LC_TimeoutGuard (LiveCheck *owner, int token)
+ :owner_ (owner),
+ token_ (token),
+ blocked_ (owner->handle_timeout_busy_ == 0)
+{
+ if (!blocked_)
+ {
+ --owner_->handle_timeout_busy_;
+ }
+}
+
+LC_TimeoutGuard::~LC_TimeoutGuard (void)
+{
+ if (blocked_)
+ {
+ return;
+ }
+
+ ++owner_->handle_timeout_busy_;
+ if (owner_->want_timeout_)
+ {
+ ACE_Time_Value delay = ACE_Time_Value::zero;
+ if (owner_->deferred_timeout_ != ACE_Time_Value::zero)
+ {
+ ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr());
+ if (owner_->deferred_timeout_ > now)
+ delay = owner_->deferred_timeout_ - now;
+ }
+ ++owner_->token_;
+ if (ImR_Locator_i::debug () > 2)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) LC_TimeoutGuard(%d)::dtor,")
+ ACE_TEXT ("scheduling new timeout(%d), delay = %d,%d\n"),
+ this->token_, owner_->token_, delay.sec(), delay.usec()));
+ }
+ owner_->reactor()->schedule_timer (owner_,
+ reinterpret_cast<void *>(owner_->token_),
+ delay);
+ owner_->want_timeout_ = false;
+ }
+ else
+ {
+ if (ImR_Locator_i::debug () > 3)
+ {
+ ORBSVCS_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) LC_TimeoutGuard(%d)::dtor,")
+ ACE_TEXT ("no pending timeouts requested\n"),
+ this->token_));
+ }
+ }
+}
+
+bool LC_TimeoutGuard::blocked (void)
+{
+ return this->blocked_;
+}
+
+//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
+
LiveCheck::LiveCheck ()
:ping_interval_(),
running_ (false),
- token_ (100)
+ token_ (100),
+ handle_timeout_busy_ (1),
+ want_timeout_ (false),
+ deferred_timeout_ (0,0)
{
}
@@ -485,15 +571,17 @@ LiveCheck::handle_timeout (const ACE_Time_Value &,
if (!this->running_)
return -1;
- bool want_reping = false;
- ACE_Time_Value next;
+ LC_TimeoutGuard tg (this, static_cast<int>(token));
+ if (tg.blocked ())
+ return 0;
+
LiveEntryMap::iterator le_end = this->entry_map_.end();
for (LiveEntryMap::iterator le = this->entry_map_.begin();
le != le_end;
++le)
{
LiveEntry *entry = le->item ();
- if (entry->validate_ping (want_reping, next))
+ if (entry->validate_ping (this->want_timeout_, this->deferred_timeout_))
{
entry->do_ping (poa_.in ());
if (ImR_Locator_i::debug () > 2)
@@ -524,7 +612,7 @@ LiveCheck::handle_timeout (const ACE_Time_Value &,
LiveEntry *entry = *pe;
if (entry != 0)
{
- if (entry->validate_ping (want_reping, next))
+ if (entry->validate_ping (this->want_timeout_, this->deferred_timeout_))
{
entry->do_ping (poa_.in ());
}
@@ -536,22 +624,6 @@ LiveCheck::handle_timeout (const ACE_Time_Value &,
}
}
-
- if (want_reping)
- {
- ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr());
- ACE_Time_Value delay = next - now;
- ++this->token_;
- if (ImR_Locator_i::debug () > 2)
- {
- ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) LiveCheck::handle_timeout(%d),")
- ACE_TEXT (" want reping(%d), delay = %d,%d\n"),
- token, this->token_, delay.sec(), delay.usec()));
- }
- this->reactor()->schedule_timer (this, reinterpret_cast<void *>(this->token_), delay);
- }
-
return 0;
}
@@ -614,10 +686,18 @@ LiveCheck::add_per_client_listener (LiveListener *l,
{
entry->add_listener (l);
- ++this->token_;
- this->reactor()->schedule_timer (this,
- reinterpret_cast<void *>(this->token_),
- ACE_Time_Value::zero);
+ if (this->handle_timeout_busy_ > 0)
+ {
+ ++this->token_;
+ this->reactor()->schedule_timer (this,
+ reinterpret_cast<void *>(this->token_),
+ ACE_Time_Value::zero);
+ }
+ else
+ {
+ this->want_timeout_ = true;
+ this->deferred_timeout_ = ACE_Time_Value::zero;
+ }
return true;
}
return false;
@@ -639,6 +719,7 @@ LiveCheck::add_poll_listener (LiveListener *l)
entry->add_listener (l);
entry->reset_status ();
+ l->status_changed (entry->status());
return this->schedule_ping (entry);
}
@@ -674,34 +755,38 @@ LiveCheck::schedule_ping (LiveEntry *entry)
ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr());
ACE_Time_Value next = entry->next_check ();
- ++this->token_;
- if (next <= now)
+
+ if (this->handle_timeout_busy_ > 0)
{
+ ACE_Time_Value delay = ACE_Time_Value::zero;
+ if (next > now)
+ {
+ delay = next - now;
+ }
+ ++this->token_;
if (ImR_Locator_i::debug () > 2)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) LiveCheck::Schdedule_ping(%d),")
- ACE_TEXT (" immediate\n"),
- this->token_));
+ ACE_TEXT ("(%P|%t) LiveCheck::schedule_ping (%d),")
+ ACE_TEXT (" delay = %d,%d\n"),
+ this->token_, delay.sec(), delay.usec()));
}
-
this->reactor()->schedule_timer (this,
reinterpret_cast<void *>(this->token_),
- ACE_Time_Value::zero);
+ delay);
}
else
{
- ACE_Time_Value delay = next - now;
if (ImR_Locator_i::debug () > 2)
{
ORBSVCS_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) LiveCheck::Schdedule_ping(%d),")
- ACE_TEXT (" delay = %d,%d\n"),
- this->token_, delay.sec(), delay.usec()));
+ ACE_TEXT ("(%P|%t) LiveCheck::schedule_ping deferred")));
+ }
+ if (!this->want_timeout_ || next < this->deferred_timeout_)
+ {
+ this->want_timeout_ = true;
+ this->deferred_timeout_ = next;
}
- this->reactor()->schedule_timer (this,
- reinterpret_cast<void *>(this->token_),
- delay);
}
return true;
}