summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Time_Service
diff options
context:
space:
mode:
authorvishal <vishal@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-01-04 03:57:02 +0000
committervishal <vishal@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-01-04 03:57:02 +0000
commitecb69670e2ec5a3c21a6b05e237e7c5abe4166b6 (patch)
tree02646a87d05ed9a4c250b40e9876154219ca9ec4 /TAO/orbsvcs/Time_Service
parentb7a8a02480108448984c6ed6afb30a0e29c95e6f (diff)
downloadATCD-ecb69670e2ec5a3c21a6b05e237e7c5abe4166b6.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/orbsvcs/Time_Service')
-rw-r--r--TAO/orbsvcs/Time_Service/Clerk_i.cpp65
-rw-r--r--TAO/orbsvcs/Time_Service/Server_i.cpp66
2 files changed, 53 insertions, 78 deletions
diff --git a/TAO/orbsvcs/Time_Service/Clerk_i.cpp b/TAO/orbsvcs/Time_Service/Clerk_i.cpp
index ba92b20fa58..ff57cf39e87 100644
--- a/TAO/orbsvcs/Time_Service/Clerk_i.cpp
+++ b/TAO/orbsvcs/Time_Service/Clerk_i.cpp
@@ -195,8 +195,6 @@ Clerk_i::get_first_IOR (void)
TAO_TRY
{
char host_name[MAXHOSTNAMELEN];
- //char machine_clerk_name[MAXHOSTNAMELEN];
- int index = 0;
ACE_OS::hostname (host_name,
MAXHOSTNAMELEN);
@@ -415,24 +413,25 @@ Clerk_i::create_clerk (void)
return 0;
}
-int
+// Check if this is the first Clerk to bind to the Naming
+// Service. If yes, then 1 is returned else 0 is returned.
+
+int
Clerk_i::if_first_clerk (CosNaming::Name clerk_context_name)
{
- TAO_TRY
- {
- this->my_name_server_->resolve
- (clerk_context_name, TAO_TRY_ENV);
- TAO_CHECK_ENV;
- }
- TAO_CATCH (CORBA::UserException, userex)
- {
+ TAO_TRY
+ {
+ this->my_name_server_->resolve
+ (clerk_context_name, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ TAO_CATCH (CORBA::UserException, userex)
+ {
ACE_UNUSED_ARG (userex);
- printf("First clerk\n");
- //TAO_TRY_ENV.print_exception ("User Exception");
return 1;
}
- TAO_ENDTRY;
- return 0;
+ TAO_ENDTRY;
+ return 0;
}
// Binds the clerk in the context ClerkContext with the name
@@ -449,44 +448,38 @@ Clerk_i::register_clerk (void)
clerk_context_name.length (1);
clerk_context_name[0].id = CORBA::string_dup ("ClerkContext");
-
- CosNaming::NamingContext_var clerk_context;
-
- // if (CORBA::is_nil (this->my_name_server_->resolve
- // (clerk_context_name, TAO_TRY_ENV)))
- if (if_first_clerk (clerk_context_name))
- {
- //TAO_TRY_ENV.clear ();
-
- clerk_context = this->my_name_server_->new_context (TAO_TRY_ENV);
- TAO_CHECK_ENV;
+ CosNaming::NamingContext_var clerk_context;
- this->my_name_server_->rebind_context (clerk_context_name,
- clerk_context.in (),
- TAO_TRY_ENV);
- TAO_CHECK_ENV;
- }
+ if (if_first_clerk (clerk_context_name))
+ {
+ clerk_context = this->my_name_server_->new_context (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
- //TAO_CHECK_ENV;
+ this->my_name_server_->rebind_context (clerk_context_name,
+ clerk_context.in (),
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
char host_name[MAXHOSTNAMELEN];
char clerk_mc_name[MAXHOSTNAMELEN];
ACE_OS::hostname (host_name,
MAXHOSTNAMELEN);
+
//CosNaming::Name clerk_name (clerk_context_name);
CosNaming::Name clerk_name;
- clerk_name.length (2);
+ clerk_name.length (2);
ACE_OS::strcpy (clerk_mc_name, "Clerk:");
ACE_OS::strcat (clerk_mc_name, host_name);
- clerk_name[0].id = CORBA::string_dup ("ClerkContext");
+ clerk_name[0].id = CORBA::string_dup ("ClerkContext");
clerk_name[1].id = CORBA::string_dup (clerk_mc_name);
this->my_name_server_->rebind (clerk_name,
- this->time_service_clerk_.in (),
- TAO_TRY_ENV);
+ this->time_service_clerk_.in (),
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
}
diff --git a/TAO/orbsvcs/Time_Service/Server_i.cpp b/TAO/orbsvcs/Time_Service/Server_i.cpp
index 30d5e994328..7413de00ee6 100644
--- a/TAO/orbsvcs/Time_Service/Server_i.cpp
+++ b/TAO/orbsvcs/Time_Service/Server_i.cpp
@@ -145,24 +145,26 @@ Server_i::create_server (void)
return 0;
}
-int
+// This function checks if this is the first server being executed. If yes,
+// the call to resolve returns an exception and 1 is returned. If there is
+// no exception 0 is returned.
+
+int
Server_i::if_first_server (CosNaming::Name &server_context_name)
{
- TAO_TRY
- {
- this->my_name_server_->resolve
- (server_context_name, TAO_TRY_ENV);
- TAO_CHECK_ENV;
- }
- TAO_CATCH (CORBA::UserException, userex)
+ TAO_TRY
+ {
+ this->my_name_server_->resolve
+ (server_context_name, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ TAO_CATCH (CORBA::UserException, userex)
{
ACE_UNUSED_ARG (userex);
- printf("First Server\n");
- //TAO_TRY_ENV.print_exception ("User Exception");
return 1;
}
- TAO_ENDTRY;
- return 0;
+ TAO_ENDTRY;
+ return 0;
}
// Bind the Server in the context 'ServerContext' with the name
@@ -179,22 +181,11 @@ Server_i::register_server (void)
CosNaming::NamingContext_var server_context;
- printf("gotchya");
- //CORBA::Object_ptr temp = this->my_name_server_->resolve
- // (server_context_name, TAO_TRY_ENV);
- //TAO_TRY_ENV.print_exception ("except:");
-
- //TAO_CHECK_ENV;
-
- if (if_first_server (server_context_name))
- {
- //printf("isnil\n");
- //TAO_TRY_ENV.print_exception ("except:");
- // This is the first server. Get a new context and bind it
- // to the naming service.
- //TAO_TRY_ENV.clear ();
- //printf("exception cleared\n");
+ // If this is the first server then get a new Naming Context
+ // and bind it to the Naming Server.
+ if (if_first_server (server_context_name))
+ {
// Get context.
server_context =
this->my_name_server_->new_context (TAO_TRY_ENV);
@@ -206,16 +197,11 @@ Server_i::register_server (void)
TAO_TRY_ENV);
TAO_CHECK_ENV;
}
- //TAO_CHECK_ENV;
char host_name[MAXHOSTNAMELEN];
char server_mc_name[MAXHOSTNAMELEN];
ACE_OS::hostname (host_name,MAXHOSTNAMELEN);
- ACE_DEBUG ((LM_DEBUG,
- "hostname %s",
- host_name));
-
CosNaming::Name server_name (server_context_name);
server_name.length (2);
@@ -223,25 +209,21 @@ Server_i::register_server (void)
strcat (server_mc_name, host_name);
server_name[1].id = CORBA::string_dup (server_mc_name);
- this->my_name_server_->bind (server_name,
- this->time_service_server_.in (),
- TAO_TRY_ENV);
+ // Bind the compound name (ServerContext(Server:<hostname>))
+ // to the Naming Server.
+
+ this->my_name_server_->rebind (server_name,
+ this->time_service_server_.in (),
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
ACE_DEBUG ((LM_DEBUG,
"Binding ServerContext -> %s\n",
server_name[1].id.in ()));
}
- TAO_CATCH (CORBA::UserException, userex)
- {
- ACE_UNUSED_ARG (userex);
- TAO_TRY_ENV.print_exception ("User Exception");
- return -1;
- }
TAO_CATCHANY
{
TAO_TRY_ENV.print_exception ("(%P|%t) Exception from init_naming_service ()\n");
- //TAO_TRY_ENV.clear ();
return -1;
}
TAO_ENDTRY;