summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-02 11:29:51 +0000
committersergio <sergio@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-02 11:29:51 +0000
commit7a5e9af83f610ac794f445288c0eb35e088bc687 (patch)
treede06a0070c2726072462493d0d4a65ab1231bf5d
parent39d1d7a553b4302f9c737f515c8bb2101a6f5840 (diff)
downloadATCD-7a5e9af83f610ac794f445288c0eb35e088bc687.tar.gz
*** empty log message ***
-rw-r--r--TAO/ChangeLog-98c12
-rw-r--r--TAO/orbsvcs/bin/Naming_Service/CosNaming_i.cpp79
-rw-r--r--TAO/orbsvcs/bin/Naming_Service/CosNaming_i.h46
-rw-r--r--TAO/orbsvcs/bin/Naming_Service/svr.cpp7
-rw-r--r--TAO/tao/orbobj.cpp17
5 files changed, 66 insertions, 95 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index a5470b5028f..0d94b5367c1 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,5 +1,17 @@
Tue Dec 2 03:12:50 1997 Sergio Flores <sergio@tango.cs.wustl.edu>
+ * tao/orbobj.cpp (resolve_name_service): Check for errors when
+ resolving using the "NameService" environment variable.
+
+ * orbsvcs/bin/Naming_Service/CosNaming_i.cpp (NS_NamingContext):
+ * orbsvcs/bin/Naming_Service/CosNaming_i.h (NS_NamingContext):
+ - Added constructor that takes a key to initialize the object,
+ instead of using the default name generation.
+ - Enabled some exceptions that are already supported.
+
+ * orbsvcs/bin/Naming_Service/svr.cpp (main): Create first naming
+ context with key "NamingContext". And minor changes.
+
* tests/Cubit/CORBAplus/IDL_Cubit/Makefile:
* tests/Cubit/CORBAplus/IDL_Cubit/README:
* tests/Cubit/CORBAplus/IDL_Cubit/clnt.cpp:
diff --git a/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.cpp b/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.cpp
index ec07e685a33..e9c1fb645d4 100644
--- a/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.cpp
+++ b/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.cpp
@@ -16,8 +16,15 @@
#include "CosNaming_i.h"
+NS_NamingContext::NS_NamingContext (const char *key)
+ : POA_CosNaming::NamingContext (key)
+{
+ if (context_.open (NS_MAP_SIZE) == -1)
+ ACE_ERROR ((LM_ERROR, "%p\n", "NS_NamingContext"));
+ // deal with fault
+}
+
NS_NamingContext::NS_NamingContext (void)
- :POA_CosNaming::NamingContext ("naming_context")
{
if (context_.open (NS_MAP_SIZE) == -1)
ACE_ERROR ((LM_ERROR, "%p\n", "NS_NamingContext"));
@@ -92,11 +99,9 @@ NS_NamingContext::bind (const CosNaming::Name& n,
if (len == 0)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
return;
}
- /* @@ */// throw CosNaming::NamingContext::InvalidName ();
// If we received compound name, resolve it to get the context in
// which the binding should take place, then perform the binding on
@@ -142,11 +147,9 @@ NS_NamingContext::rebind (const CosNaming::Name& n,
if (len == 0)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
return;
}
- /* @@ */// throw CosNaming::NamingContext::InvalidName ();
// If we received compound name, resolve it to get the context in
// which the rebinding should take place, then perform the rebinding
@@ -186,11 +189,9 @@ NS_NamingContext::bind_context (const CosNaming::Name &n,
if (len == 0)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
return;
}
- /* @@ */// throw CosNaming::NamingContext::InvalidName ();
// If we received compound name, resolve it to get the context in
// which the binding should take place, then perform the binding on
@@ -215,12 +216,11 @@ NS_NamingContext::bind_context (const CosNaming::Name &n,
if (context_.bind (name, entry) == 1)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::AlreadyBound);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::AlreadyBound);
return;
}
- /* @@ */// throw CosNaming::NamingContext::AlreadyBound ();
- // May need to add case dealing with -1.
+
+ // May need to add case dealing with -1. @@
}
}
@@ -236,11 +236,9 @@ NS_NamingContext::rebind_context (const CosNaming::Name &n,
if (len == 0)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
return;
}
- /* @@ */// throw CosNaming::NamingContext::InvalidName ();
// If we received compound name, resolve it to get the context in
// which the rebinding should take place, then perform the rebinding
@@ -280,11 +278,9 @@ NS_NamingContext::resolve (const CosNaming::Name& n,
if (len == 0)
{
IT_env.clear ();
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
return 0;
}
- /* @@ *//// throw CosNaming::NamingContext::InvalidName ();
// resolve the first component of the name
NS_ExtId name (n[0].id, n[0].kind);
@@ -292,8 +288,8 @@ NS_NamingContext::resolve (const CosNaming::Name& n,
if (context_.find (name, entry) == -1)
{
IT_env.clear ();
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotFound (CosNaming::NamingContext::not_object, n));
IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
+ // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotFound (CosNaming::NamingContext::not_object, n));
return 0;
}
/* @@ */// throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_object, n);
@@ -317,8 +313,8 @@ NS_NamingContext::resolve (const CosNaming::Name& n,
else
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotFound (CosNaming::NamingContext::not_context, n));
+ IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
+ //IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotFound (CosNaming::NamingContext::not_context, n));
return 0;
}
/* @@ */// throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_context, n);
@@ -349,11 +345,9 @@ NS_NamingContext::unbind (const CosNaming::Name& n,
if (len == 0)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::InvalidName);
return;
}
- /* @@ *//// throw CosNaming::NamingContext::InvalidName ();
// If we received compound name, resolve it to get the context in
// which the unbinding should take place, then perform the unbinding
@@ -375,8 +369,8 @@ NS_NamingContext::unbind (const CosNaming::Name& n,
if (context_.unbind (name) == -1)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotFound (CosNaming::NamingContext::not_object, n));
+ IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
+ //IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotFound (CosNaming::NamingContext::not_object, n));
return;
}
/* @@ */// throw CosNaming::NamingContext::NotFound (CosNaming::NamingContext::not_object, n);
@@ -390,47 +384,34 @@ NS_NamingContext::new_context (CORBA::Environment &IT_env)
ACE_UNUSED_ARG (IT_env);
NS_NamingContext *c = new NS_NamingContext;
- // CosNaming::NamingContext_ptr cont
- //= new TIE_CosNaming_NamingContext (NS_NamingContext) (c);
-
- // c->initialize (cont);
return c->_duplicate (c);
}
CosNaming::NamingContext_ptr
NS_NamingContext::bind_new_context (const CosNaming::Name& n,
- CORBA::Environment &IT_env)
+ CORBA::Environment &IT_env)
{
NS_NamingContext *c = new NS_NamingContext;
- // CosNaming::NamingContext_ptr cont =
- // new TIE_CosNaming_NamingContext (NS_NamingContext) (c);
-
- // c->initialize (cont);
-
- bind_context (n, c, IT_env);
- CORBA::release (c);
- CORBA::release (c);
- CORBA::release (c);
- CORBA::release (c);
+ bind_context (n, c, IT_env);
+
+ // release object if exception occurs.
+ if (IT_env.exception () != 0)
+ CORBA::release (c);
+
return c->_duplicate (c);
}
void
NS_NamingContext::destroy (CORBA::Environment &IT_env)
{
- // Macro to avoid "warning: unused parameter" type warning.
- ACE_UNUSED_ARG (IT_env);
-
if (context_.current_size () != 0)
{
IT_env.clear ();
- IT_env.exception (new CORBA::UNKNOWN (CORBA::COMPLETED_NO));
- // IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotEmpty);
+ IT_env.exception (new ACE_NESTED_CLASS (CosNaming,NamingContext)::NotEmpty);
return;
}
- /* @@ */// throw CosNaming::NamingContext::NotEmpty ();
// destroy context
CORBA::release (tie_ref_);
diff --git a/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.h b/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.h
index 6ef104a7a23..6d00ce8f39f 100644
--- a/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.h
+++ b/TAO/orbsvcs/bin/Naming_Service/CosNaming_i.h
@@ -42,6 +42,9 @@ class NS_NamingContext : public POA_CosNaming::NamingContext
NS_NamingContext (void);
// default constructor.
+ NS_NamingContext (const char *key);
+ // constructor
+
~NS_NamingContext (void);
// destructor.
@@ -81,20 +84,20 @@ class NS_NamingContext : public POA_CosNaming::NamingContext
protected:
// = These are the helper methods used by other methods.
-
+
CosNaming::NamingContext_ptr get_context (const CosNaming::Name &name);
// This is used by methods that need to resolve a compound name to
// get the reference to the target context before performing the
// actual operation (e.g. bind, unbind, etc.) Takes a full name
// (including the last component that doesn't need to be resolved)
// Returns a pointer to the target context.
-
+
private:
HASH_MAP context_;
// This implementation of NamingContext uses ACE thread-safe Hash
// Map for storage and manipulation of name-object bindings.
-
+
CosNaming::NamingContext_ptr tie_ref_;
// Stores CORBA object reference to the TIE object this object
// implements. This is needed to implement the <destroy> method.
@@ -133,41 +136,4 @@ class NS_BindingIterator : public POA_CosNaming::BindingIterator
// A pointer to the hash map iterator.
};
-
-
-
-// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-#if 0
-class CosNaming_i : public POA_CosNaming
- // = TITLE
- // Integrates the naming service with the
- // generated skeleton.
- // = DESCRIPTION
- // Implementation of the naming service at the servant side.
-{
- public:
- CosNaming_i (void);
- // constructor
-
- ~CosNaming_i (void);
- // destructor
-
- static CosNaming::NamingContext_ptr _bind (const char *host,
- CORBA::ULong port,
- const char *key,
- CORBA::Environment &env);
-
- NamingContext & naming_context (void)
- {
- return nc;
- }
-
- private:
- NS_NamingContext nc;
- // not sure about this.
-};
-#endif
-
-
#endif /* COSNAMING_I_H */
diff --git a/TAO/orbsvcs/bin/Naming_Service/svr.cpp b/TAO/orbsvcs/bin/Naming_Service/svr.cpp
index 2921db2be04..d335aa074c5 100644
--- a/TAO/orbsvcs/bin/Naming_Service/svr.cpp
+++ b/TAO/orbsvcs/bin/Naming_Service/svr.cpp
@@ -115,13 +115,13 @@ main (int argc, char ** argv)
1);
// Create a naming context object.
- NS_NamingContext *naming_context = new NS_NamingContext;
+ NS_NamingContext *naming_context = new NS_NamingContext ("NameService");
// Stringify the objref we'll be implementing, and print it to
// stdout. Someone will take that string and give it to a
// client. Then release the object.
CORBA::String str;
- str = orb_ptr->object_to_string (naming_context, env);
+ str = ACE_OS::strdup (orb_ptr->object_to_string (naming_context, env));
if (env.exception () != 0)
{
@@ -162,6 +162,9 @@ main (int argc, char ** argv)
ACE_DEBUG ((LM_DEBUG, "The multicast server setup is done.\n"));
#endif /* ACE_HAS_IP_MULTICAST */
+ // free memory with "free" because we used strdup which uses malloc
+ ACE_OS::free (str);
+
// Handle requests for this object until we're killed, or one of the
// methods asks us to exit.
if (orb_ptr->run () == -1)
diff --git a/TAO/tao/orbobj.cpp b/TAO/tao/orbobj.cpp
index 63efbb0e3eb..75fba5d214a 100644
--- a/TAO/tao/orbobj.cpp
+++ b/TAO/tao/orbobj.cpp
@@ -337,6 +337,8 @@ CORBA_ORB::resolve_poa (void)
CORBA_Object_ptr
CORBA_ORB::resolve_name_service (void)
{
+ CORBA::Environment env;
+
// First check to see if we've already initialized this.
if (this->name_service_ != CORBA_Object::_nil ())
// @@ Someone please double-check this ;-)
@@ -353,10 +355,15 @@ CORBA_ORB::resolve_name_service (void)
if (name_service_ior != 0)
{
- CORBA::Environment env;
this->name_service_ =
this->string_to_object (name_service_ior, env);
- return this->name_service_;
+
+ // check for errors
+ if (env.exception () != 0)
+ this->name_service_ = CORBA_Object::_nil ();
+
+ // Return ior.
+ return CORBA_Object::_duplicate (this->name_service_);
}
// Fourth, use UDP multicast to locate the naming service.
@@ -400,7 +407,6 @@ CORBA_ORB::resolve_name_service (void)
return CORBA_Object::_nil ();
}
-
if (response.get_local_addr (response_addr) == -1)
{
ACE_ERROR ((LM_ERROR, "get_local_addr failed.\n"));
@@ -414,6 +420,8 @@ CORBA_ORB::resolve_name_service (void)
// Send multicast of one byte, enough to wake up server.
ssize_t n_bytes = multicast.send ((char *) &reply_port,
sizeof reply_port);
+
+ // check for errors
if (n_bytes == -1)
return CORBA_Object::_nil ();
@@ -426,6 +434,7 @@ CORBA_ORB::resolve_name_service (void)
// Wait for response until TAO_DEFAULT_NAME_SERVER_TIMEOUT.
ACE_Time_Value timeout (TAO_DEFAULT_NAME_SERVER_TIMEOUT);
+ // receive response message
n_bytes = response.recv (buf,
BUFSIZ,
remote_addr,
@@ -435,6 +444,7 @@ CORBA_ORB::resolve_name_service (void)
// Close endpoint for response.
int retval = response.close ();
+ // check for errors
if (n_bytes == -1 || retval == -1)
return CORBA_Object::_nil ();
@@ -446,7 +456,6 @@ CORBA_ORB::resolve_name_service (void)
buf));
// convert ior to an object reference
- CORBA::Environment env;
this->name_service_ =
this->string_to_object ((CORBA::String) buf, env);