summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2013-04-01 23:53:42 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2013-04-01 23:53:42 +0000
commite100643f5dbd97e02bbac0968cc46c6ca861f075 (patch)
treea1657e9deb4f6a49fc3f03453dfc0836a3bc2e02
parent0d66f24929411d0536d137ef2caccc1f5cdbfaad (diff)
downloadATCD-e100643f5dbd97e02bbac0968cc46c6ca861f075.tar.gz
Mon Apr 1 23:52:37 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
-rw-r--r--TAO/ChangeLog_Asynch_ImR8
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp42
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h3
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp96
4 files changed, 108 insertions, 41 deletions
diff --git a/TAO/ChangeLog_Asynch_ImR b/TAO/ChangeLog_Asynch_ImR
index bae48aa3f08..12334e45a4f 100644
--- a/TAO/ChangeLog_Asynch_ImR
+++ b/TAO/ChangeLog_Asynch_ImR
@@ -1,3 +1,11 @@
+Mon Apr 1 23:52:37 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
+
+ * orbsvcs/ImplRepo_Service/AsyncAccessManager.h:
+ * orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp:
+ * orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp:
+
+ More memory management and state machine improvments
+
Mon Apr 1 21:28:42 UTC 2013 Phil Mesnier <mesnier_p@ociweb.com>
* orbsvcs/ImplRepo_Service/AsyncAccessManager.h:
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp
index 16d01398260..3d96b272583 100644
--- a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp
@@ -20,21 +20,31 @@ AsyncAccessManager::AsyncAccessManager (const Server_Info &info,
refcount_(1),
lock_()
{
- ACE_DEBUG ((LM_DEBUG,"New AAM: this = %x, name = %s\n",
+ ACE_DEBUG ((LM_DEBUG,"AAM(%x), ctor, name = %s\n",
this, info.name.c_str()));
this->info_ = new Server_Info (info);
}
AsyncAccessManager::~AsyncAccessManager (void)
{
- ACE_DEBUG ((LM_DEBUG, "AAM (%x): dtor\n", this));
+ ACE_DEBUG ((LM_DEBUG, "AAM (%x): dtor, name = %s\n", this,
+ info_->name.c_str()));
delete this->info_;
}
+void
+AsyncAccessManager::started_running (void)
+{
+ this->status_ = AAM_SERVER_STARTED_RUNNING;
+}
+
bool
AsyncAccessManager::has_server (const char *s)
{
- return ACE_OS::strcmp (this->info_->name.c_str(),s) == 0;
+ int result = ACE_OS::strcmp (this->info_->name.c_str(),s);
+ ACE_DEBUG ((LM_DEBUG, "AAM (%x): has_server test, my name = %s, s = %s result = %d\n",
+ this, info_->name.c_str(), s, result));
+ return result == 0;
}
void
@@ -52,10 +62,11 @@ AsyncAccessManager::add_interest (ImR_ResponseHandler *rh)
this->info_->name.c_str(), this->status_, this->rh_list_.size()));
}
- if (this->status_ == AAM_SERVER_READY)
+ if (this->status_ == AAM_SERVER_READY || this->status_ == AAM_SERVER_STARTED_RUNNING)
{
if (this->locator_.pinger().is_alive (this->info_->name.c_str()))
{
+ this->status_ = AAM_SERVER_READY;
this->final_state();
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) AsyncAccessManager::add_interest: ")
@@ -65,7 +76,7 @@ AsyncAccessManager::add_interest (ImR_ResponseHandler *rh)
}
}
- if (this->status_ == AAM_INIT || this->status_ == AAM_SERVER_READY)
+ if (this->status_ == AAM_INIT || this->status_ == AAM_SERVER_READY || this->status_ == AAM_SERVER_STARTED_RUNNING)
{
// This is not a leak. The listener registers with
// the pinger and will delete itself when done.
@@ -82,7 +93,14 @@ AsyncAccessManager::add_interest (ImR_ResponseHandler *rh)
}
else
{
- this->status (AAM_WAIT_FOR_PING);
+ if (this->status_ == AAM_SERVER_STARTED_RUNNING)
+ {
+ this->status (AAM_WAIT_FOR_ALIVE);
+ }
+ else
+ {
+ this->status (AAM_WAIT_FOR_PING);
+ }
}
}
@@ -164,13 +182,13 @@ AsyncAccessManager::status (AAM_Status s)
void
AsyncAccessManager::activator_replied (bool success)
{
- if (this->locator_.debug() > 0)
- {
+ // if (this->locator_.debug() > 0)
+ // {
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) AsyncAccessManager::activator_replied: ")
ACE_TEXT ("success = %d, status = %d\n"),
success, this->status_));
- }
+ // }
if (success)
{
this->status (AAM_WAIT_FOR_RUNNING);
@@ -192,13 +210,13 @@ AsyncAccessManager::server_is_shutting_down (void)
void
AsyncAccessManager::server_is_running (const char *partial_ior)
{
- if (this->locator_.debug() > 0)
- {
+ // if (this->locator_.debug() > 0)
+ // {
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) AsyncAccessManager::server_is_running: ")
ACE_TEXT ("name = %C, status = %d\n"),
this->info_->name.c_str(), this->status_));
- }
+ // }
this->status (AAM_WAIT_FOR_ALIVE);
this->info_->partial_ior = partial_ior;
diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h
index 3ffe1530895..b89669a3f80 100644
--- a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h
+++ b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h
@@ -32,6 +32,7 @@ struct Server_Info;
enum AAM_Status
{
AAM_INIT,
+ AAM_SERVER_STARTED_RUNNING,
AAM_ACTIVATION_SENT,
AAM_WAIT_FOR_RUNNING,
AAM_WAIT_FOR_PING,
@@ -72,6 +73,8 @@ class AsyncAccessManager
~AsyncAccessManager (void);
+ void started_running (void);
+
bool has_server (const char *name);
void add_interest (ImR_ResponseHandler *rh);
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
index 2370a7080a6..c94a248264a 100644
--- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
+++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp
@@ -571,11 +571,11 @@ ImR_Locator_i::add_or_update_server
ACE_TEXT ("ImR: Cannot add/update server <%C> due to locked ")
ACE_TEXT ("database.\n"),
server));
- CORBA::NO_PERMISSION ex
- (CORBA::SystemException::_tao_minor_code
- (TAO_IMPLREPO_MINOR_CODE,0),
- CORBA::COMPLETED_NO);
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ CORBA::Exception *ex =
+ new CORBA::NO_PERMISSION (CORBA::SystemException::_tao_minor_code
+ (TAO_IMPLREPO_MINOR_CODE,0),
+ CORBA::COMPLETED_NO);
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
_tao_rh->add_or_update_server_excep (&h);
return;
}
@@ -693,11 +693,11 @@ ImR_Locator_i::remove_server
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ImR: Can't remove server <%C> due to locked database.\n"),
name));
- CORBA::NO_PERMISSION ex
- (CORBA::SystemException::_tao_minor_code
- (TAO_IMPLREPO_MINOR_CODE, 0),
- CORBA::COMPLETED_NO);
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ CORBA::Exception *ex =
+ new CORBA::NO_PERMISSION (CORBA::SystemException::_tao_minor_code
+ (TAO_IMPLREPO_MINOR_CODE, 0),
+ CORBA::COMPLETED_NO);
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
_tao_rh->remove_server_excep (&h);
return;
}
@@ -737,8 +737,8 @@ ImR_Locator_i::remove_server
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ImR: Can't remove unknown server <%C>.\n"), name));
- ImplementationRepository::NotFound ex;
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ CORBA::Exception *ex = new ImplementationRepository::NotFound;
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
_tao_rh->remove_server_excep (&h);
return;
}
@@ -782,8 +782,8 @@ ImR_Locator_i::shutdown_server
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ImR: shutdown_server () Cannot find info for server <%C>\n"),
server));
- ImplementationRepository::NotFound ex;
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ CORBA::Exception *ex = new ImplementationRepository::NotFound;
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
_tao_rh->shutdown_server_excep (&h);
return;
}
@@ -795,9 +795,16 @@ ImR_Locator_i::shutdown_server
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("ImR: shutdown_server () Cannot connect to server <%C>\n"),
server));
- ImplementationRepository::NotFound ex;
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
- _tao_rh->shutdown_server_excep (&h);
+ CORBA::Exception *ex = new ImplementationRepository::NotFound;
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
+ try
+ {
+ _tao_rh->shutdown_server_excep (&h);
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ex._tao_print_exception (ACE_TEXT ("reporting connect error\n"));
+ }
return;
}
@@ -809,7 +816,7 @@ ImR_Locator_i::shutdown_server
ImplementationRepository::ServerObject::_unchecked_narrow (obj.in ());
server->shutdown ();
}
- catch (CORBA::TIMEOUT &ex)
+ catch (CORBA::TIMEOUT &to_ex)
{
info.edit ()->reset ();
// Note : This is a good thing. It means we didn't waste our time waiting for
@@ -820,7 +827,7 @@ ImR_Locator_i::shutdown_server
ACE_TEXT ("ImR: Timeout while waiting for <%C> shutdown.\n"),
server));
}
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (to_ex._tao_duplicate());
_tao_rh->shutdown_server_excep (&h);
return;
}
@@ -902,6 +909,27 @@ ImR_Locator_i::server_is_running
ior.in (),
ImplementationRepository::ServerObject::_nil ()
);
+
+ Server_Info_Ptr temp_info = this->repository_->get_server(name);
+ if (temp_info.null ())
+ {
+ if (this->debug_ > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("ImR: Auto adding failed, giving up <%C>\n"),
+ name.c_str ()));
+ }
+
+ _tao_rh->server_is_running ();
+ return;
+ }
+
+ AsyncAccessManager *aam_raw;
+ ACE_NEW (aam_raw, AsyncAccessManager (*temp_info, true, *this));
+ AsyncAccessManager_ptr aam (aam_raw);
+ aam->started_running ();
+ int result = this->aam_set_.insert (aam);
+ ACE_DEBUG ((LM_DEBUG, "ImR_Locator_i::server_is_running insert_aam returned %d\n", result));
}
else
{
@@ -927,7 +955,17 @@ ImR_Locator_i::server_is_running
AsyncAccessManager_ptr aam(this->find_aam (name.c_str()));
if (*aam != 0)
aam->server_is_running (partial_ior);
- ACE_DEBUG ((LM_DEBUG, "Server_Is_Running, aam ptr should die\n"));
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG, "Server_Is_Running, %s not found in aam set\n",
+ name.c_str()));
+ AsyncAccessManager *aam_raw;
+ ACE_NEW (aam_raw, AsyncAccessManager (*info, true, *this));
+ AsyncAccessManager_ptr aam (aam_raw);
+ aam->started_running ();
+ int result = this->aam_set_.insert (aam);
+ ACE_DEBUG ((LM_DEBUG, "ImR_Locator_i::server_is_running insert_aam returned %d\n", result));
+ }
}
_tao_rh->server_is_running ();
}
@@ -1005,7 +1043,7 @@ ImR_Locator_i::find
}
catch (CORBA::Exception &ex)
{
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
_tao_rh->find_excep (&h);
return;
}
@@ -1108,7 +1146,7 @@ ImR_Locator_i::list
}
catch (CORBA::Exception& ex)
{
- ImplementationRepository::AMH_AdministrationExceptionHolder h (&ex);
+ ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
_tao_rh->list_excep (&h);
}
}
@@ -1292,16 +1330,16 @@ ImR_Locator_i::remove_aam (AsyncAccessManager_ptr &aam)
AsyncAccessManager *
ImR_Locator_i::find_aam (const char *name)
{
- for (AAM_Set::ITERATOR i(this->aam_set_);
- !i.done();
- i.advance ())
+ ACE_DEBUG ((LM_DEBUG, "ImR_Locator_i::find_aam called for %s, set size = %d\n", name, aam_set_.size()));
+
+ for (AAM_Set::ITERATOR i = this->aam_set_.begin();
+ i != this->aam_set_.end();
+ ++i)
{
- AsyncAccessManager_ptr *entry = 0;
- i.next (entry);
- if (*(*entry) != 0 && (*entry)->has_server (name))
+ if ((*i)->has_server (name))
{
ACE_DEBUG ((LM_DEBUG, "ImR_Locator_i::find_aam add ref and return\n"));
- return (*entry)._retn()->add_ref();
+ return (*i)->add_ref();
}
}
return 0;