summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cleeland <chris.cleeland@gmail.com>1997-05-22 16:57:08 +0000
committerChris Cleeland <chris.cleeland@gmail.com>1997-05-22 16:57:08 +0000
commite453c1c3709ed13ef2a45e1b7f9e6de58ef63098 (patch)
tree519f3b3b42444b2fb825c4b001cbbc4533b43869
parent5082d18b5363fdd2a025a58d15e00d66ff6a6c5c (diff)
downloadATCD-e453c1c3709ed13ef2a45e1b7f9e6de58ef63098.tar.gz
duh
-rw-r--r--TAO/ChangeLog-98c30
-rw-r--r--TAO/IIOP/lib/factories.cpp16
-rw-r--r--TAO/IIOP/lib/giop.cpp58
-rw-r--r--TAO/IIOP/lib/objtable.cpp2
-rw-r--r--TAO/IIOP/lib/optable.cpp4
-rw-r--r--TAO/IIOP/test/clnt.cpp376
-rw-r--r--TAO/IIOP/test/cubitS.cpp24
-rw-r--r--TAO/IIOP/test/method_db.i2
-rw-r--r--TAO/IIOP/test/svr.cpp21
9 files changed, 310 insertions, 223 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index dddaf463604..ef6ab47d7d9 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,33 @@
+Wed May 22 11:31:42 1997 Chris Cleeland <cleeland@cs.wustl.edu>
+
+ * IIOP/test/svr.cpp: Added better error checking and messages, and
+ performed general re-formatting.
+
+ * IIOP/test/method_db.i (initialize_method_db): Changed arg type
+ to use a pointer to the abstract class TAO_Operation_Table.
+
+ * IIOP/test/cubitS.cpp (_skel_Cubit::_skel_Cubit): Added better
+ error checking and messages. Also defaulted to use the linear
+ object table implementation rather than the hashed to simplify
+ debugging.
+
+ * IIOP/test/clnt.cpp: Moved some code around so that more of the
+ code is common is less is specific to VxWorks and other platforms.
+ Also did general re-formatting.
+
+ * IIOP/lib/optable.cpp (TAO_Linear_OpTable::find): Initialization
+ of the loop variable makes the loop work properly.
+
+ * IIOP/lib/objtable.cpp (TAO_Dynamic_Hash_ObjTable::find):
+ Explicitly specified length of object key in CTOR for ACE_CString
+ because object keys are not zero-terminated.
+
+ * IIOP/lib/giop.cpp: Added newlines to the end of all ACE_DEBUG()
+ messages.
+
+ * IIOP/lib/factories.cpp: Added template specializations for
+ ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>.
+
Tue May 22 09:32:41 1997 Brian Mendel <bmendel@mdc.com>
* IIOP/lib/cdr.h: Deleted #define old_value ACE_INLINE and
diff --git a/TAO/IIOP/lib/factories.cpp b/TAO/IIOP/lib/factories.cpp
index 98795912434..93b46e84fe0 100644
--- a/TAO/IIOP/lib/factories.cpp
+++ b/TAO/IIOP/lib/factories.cpp
@@ -4,6 +4,22 @@
# include "factories.i"
#endif
+// Template specializations which allow the cached connection manager
+// to work better.
+
+size_t
+ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>::hash_i (const ACE_INET_Addr &addr) const
+{
+ return addr.get_ip_address () + addr.get_port_number ();
+}
+
+int
+ACE_Hash_Addr<ACE_INET_Addr, TAO_Client_Connection_Handler>::compare_i (const ACE_INET_Addr &a1,
+ const ACE_INET_Addr &a2) const
+{
+ return a1 != a2;
+}
+
int
TAO_Client_Connection_Handler::open(void *)
{
diff --git a/TAO/IIOP/lib/giop.cpp b/TAO/IIOP/lib/giop.cpp
index 536c9ae023e..3d37e3a19f0 100644
--- a/TAO/IIOP/lib/giop.cpp
+++ b/TAO/IIOP/lib/giop.cpp
@@ -115,7 +115,7 @@ dump_msg (const char *label,
(ptr[7] <= GIOP::MessageError) ? names [ptr[7]] : "UNKNOWN TYPE"));
if (TAO_debug_level >= 4)
- ACE_HEX_DUMP ((LM_DEBUG, (const char*)ptr, len, "(%P|%t) data bytes"));
+ ACE_HEX_DUMP ((LM_DEBUG, (const char*)ptr, len, "(%P|%t) data bytes\n"));
}
}
@@ -188,15 +188,15 @@ GIOP::send_message (CDR &stream,
if (writelen == -1)
{
- ACE_DEBUG ((LM_ERROR, "(%P|%t) OutgoingMessage::writebuf() $p"));
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) closing conn %d after fault", connection));
+ ACE_DEBUG ((LM_ERROR, "(%P|%t) OutgoingMessage::writebuf() $p\n"));
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) closing conn %d after fault\n", connection));
ACE_OS::closesocket (connection);
connection = ACE_INVALID_HANDLE;
return CORBA_B_FALSE;
}
else if (writelen == 0)
{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) OutgoingMessage::writebuf () ... EOF, closing conn %d", connection));
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) OutgoingMessage::writebuf () ... EOF, closing conn %d\n", connection));
ACE_OS::closesocket (connection);
connection = ACE_INVALID_HANDLE;
return CORBA_B_FALSE;
@@ -265,7 +265,7 @@ GIOP::close_connection (ACE_HANDLE &handle,
(void) ACE::send (handle, close_message, TAO_GIOP_HEADER_LEN);
(void) ACE_OS::shutdown (handle, 2);
(void) ACE_OS::closesocket (handle);
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) shut down socket %d", handle));
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) shut down socket %d\n", handle));
handle = ACE_INVALID_HANDLE;
}
@@ -293,7 +293,7 @@ send_error (ACE_HANDLE &handle)
(void) ACE::send (handle, error_message, TAO_GIOP_HEADER_LEN);
(void) ACE_OS::shutdown (handle, 2);
(void) ACE_OS::closesocket (handle);
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) aborted socket %d", handle));
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) aborted socket %d\n", handle));
handle = ACE_INVALID_HANDLE;
}
@@ -400,7 +400,7 @@ GIOP::read_message (ACE_SOCK_Stream &connection,
{
if (len == 0)
{ // EOF
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Header EOF ... peer probably aborted connection %d",
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Header EOF ... peer probably aborted connection %d\n",
connection.get_handle()));
return EndOfFile;
// XXX should probably find some way to report this without
@@ -409,9 +409,9 @@ GIOP::read_message (ACE_SOCK_Stream &connection,
//
}
else if (len < 0) // error
- ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message header socket error %p"));
+ ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message header socket error %p\n"));
else // short read ...
- ACE_DEBUG ((LM_ERROR, "(%P|%t) read message header failed (short)"));
+ ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message header failed (short)\n"));
env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE));
return MessageError;
@@ -429,7 +429,7 @@ GIOP::read_message (ACE_SOCK_Stream &connection,
&& msg.buffer [3] == 'P'))
{
env.exception (new CORBA_MARSHAL (COMPLETED_MAYBE)); // header
- ACE_DEBUG((LM_DEBUG, "bad header, magic word"));
+ ACE_DEBUG((LM_DEBUG, "bad header, magic word\n"));
return MessageError;
}
@@ -439,7 +439,7 @@ GIOP::read_message (ACE_SOCK_Stream &connection,
if (!(msg.buffer [4] == MY_MAJOR && msg.buffer [5] <= MY_MINOR))
{
env.exception (new CORBA_MARSHAL (COMPLETED_MAYBE)); // header
- ACE_DEBUG((LM_DEBUG, "bad header, version"));
+ ACE_DEBUG((LM_DEBUG, "bad header, version\n"));
return MessageError;
}
@@ -476,15 +476,15 @@ GIOP::read_message (ACE_SOCK_Stream &connection,
if (len != (int) message_size)
{
if (len == 0)
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) read message body, EOF on handle %d", connection.get_handle()));
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) GIOP::read_message body, EOF on handle %d\n", connection.get_handle()));
else if (len < 0)
- ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message () body %p"));
+ ACE_DEBUG ((LM_ERROR, "(%P|%t) GIOP::read_message () body %p\n"));
else
- ACE_DEBUG ((LM_ERROR, "(%P|%t) short read, only %d of %d bytes", len, message_size));
+ ACE_DEBUG ((LM_ERROR, "(%P|%t) short read, only %d of %d bytes\n", len, message_size));
// clean up, and ...
env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE)); // body
- ACE_DEBUG ((LM_DEBUG, "couldn't read rest of message"));
+ ACE_DEBUG ((LM_DEBUG, "couldn't read rest of message\n"));
return MessageError;
}
@@ -880,7 +880,7 @@ GIOP::Invocation::invoke (CORBA_ExceptionList &exceptions,
// be indicative of client bugs (lost track of input stream) or
// server bugs; maybe the request was acted on, maybe not, we
// can't tell.
- ACE_DEBUG((LM_DEBUG, "(%P|%t) illegal message in response to my Request!"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) illegal message in response to my Request!\n"));
env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE));
// FALLTHROUGH ...
@@ -935,7 +935,7 @@ GIOP::Invocation::invoke (CORBA_ExceptionList &exceptions,
{
send_error (handler_->peer());
env.exception (new CORBA_COMM_FAILURE (COMPLETED_MAYBE));
- ACE_DEBUG((LM_DEBUG, "(%P|%t) bad Response header"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) bad Response header\n"));
return SYSTEM_EXCEPTION;
}
@@ -1038,7 +1038,7 @@ GIOP::Invocation::invoke (CORBA_ExceptionList &exceptions,
!= CORBA_TypeCode::TRAVERSE_CONTINUE)
{
delete exception;
- ACE_DEBUG((LM_ERROR, "(%P|%t) invoke, unmarshal %s exception %s",
+ ACE_DEBUG((LM_ERROR, "(%P|%t) invoke, unmarshal %s exception %s\n",
(reply_status == USER_EXCEPTION) ? "user" : "system",
exception_id));
send_error (handler_->peer());
@@ -1163,7 +1163,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer,
case LocateReply:
case CloseConnection:
default: // Unknown message
- ACE_DEBUG((LM_DEBUG, "(%P|%t) Illegal message received by server"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) Illegal message received by server\n"));
env.exception (new CORBA_COMM_FAILURE (COMPLETED_NO));
// FALLTHROUGH
@@ -1229,20 +1229,20 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer,
#ifdef DEBUG
if (TAO_debug_level >= 3)
{
- ACE_DEBUG((LM_DEBUG, "(%P|%t) %sRequest ID %#lx from FD %d",
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) %sRequest ID %#lx from FD %d\n",
req.response_expected ? "" : "Oneway ",
req.request_id, peer.get_handle ()));
if (TAO_debug_level >= 4)
{
ACE_HEX_DUMP((LM_DEBUG, (char*)req.object_key.buffer,
- req.object_key.length, "(%P|%t) object key"));
- ACE_DEBUG((LM_DEBUG, "(%P|%t) opname '%s'", req.operation));
+ req.object_key.length, "(%P|%t) object key\n"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) opname '%s'\n", req.operation));
if (req.requesting_principal)
ACE_HEX_DUMP((LM_DEBUG, (char*)req.requesting_principal->id.buffer,
req.requesting_principal->id.length,
- "(%P|%t) client principal"));
+ "(%P|%t) client principal\n"));
else
- ACE_DEBUG((LM_DEBUG, "(%P|%t) client principal (EMPTY)"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) client principal (EMPTY)\n"));
}
// NOTE: describe any service context, and how many bytes
@@ -1287,7 +1287,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer,
}
else if (status == OBJECT_FORWARD)
{
- ACE_DEBUG((LM_DEBUG, "(%P|%t) forwarding Request message"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) forwarding Request message\n"));
response.put_ulong (LOCATION_FORWARD);
CDR::encoder (_tc_CORBA_Object,
&fwd_ref,
@@ -1375,7 +1375,7 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer,
if (check_forward == 0)
{
response.put_ulong (OBJECT_HERE);
- ACE_DEBUG((LM_DEBUG, "(%P|%t) LocateRequest response: object is (always) here!"));
+ ACE_DEBUG((LM_DEBUG, "(%P|%t) LocateRequest response: object is (always) here!\n"));
}
else
{
@@ -1386,14 +1386,14 @@ GIOP::incoming_message (ACE_SOCK_Stream &peer,
if (status == OBJECT_FORWARD)
{
- ACE_DEBUG((LM_DEBUG, "LocateRequest response: forward requests"));
+ ACE_DEBUG((LM_DEBUG, "LocateRequest response: forward requests\n"));
CDR::encoder (_tc_CORBA_Object, &fwd_ref, 0,
&response, env);
}
else if (status == OBJECT_HERE)
- ACE_DEBUG((LM_DEBUG, "LocateRequest response: object is here!"));
+ ACE_DEBUG((LM_DEBUG, "LocateRequest response: object is here!\n"));
else
- ACE_DEBUG((LM_DEBUG, "LocateRequest response: no such object"));
+ ACE_DEBUG((LM_DEBUG, "LocateRequest response: no such object\n"));
}
(void) send_message (response, peer);
}
diff --git a/TAO/IIOP/lib/objtable.cpp b/TAO/IIOP/lib/objtable.cpp
index 132c3032bf1..232d0eb4954 100644
--- a/TAO/IIOP/lib/objtable.cpp
+++ b/TAO/IIOP/lib/objtable.cpp
@@ -24,7 +24,7 @@ int
TAO_Dynamic_Hash_ObjTable::find (const CORBA_OctetSeq &key,
CORBA_Object_ptr &obj)
{
- ACE_CString objkey ((char *) key.buffer);
+ ACE_CString objkey ((char *) key.buffer, key.length);
return this->hash_.find (objkey, obj);
}
diff --git a/TAO/IIOP/lib/optable.cpp b/TAO/IIOP/lib/optable.cpp
index 3766fbcf578..d78817b8a47 100644
--- a/TAO/IIOP/lib/optable.cpp
+++ b/TAO/IIOP/lib/optable.cpp
@@ -70,9 +70,7 @@ TAO_Linear_OpTable::find (const CORBA_String &opname,
{
ACE_ASSERT (this->next_ <= this->tablesize_);
- for (CORBA_ULong i;
- i < this->next_;
- i++)
+ for (CORBA_ULong i = 0; i < this->next_; i++)
if (!ACE_OS::strncmp (opname, this->tbl_[i].opname, ACE_OS::strlen (opname)))
{
skel_ptr = this->tbl_[i].skel_ptr;
diff --git a/TAO/IIOP/test/clnt.cpp b/TAO/IIOP/test/clnt.cpp
index 7a4211d4521..367d463de66 100644
--- a/TAO/IIOP/test/clnt.cpp
+++ b/TAO/IIOP/test/clnt.cpp
@@ -47,10 +47,8 @@ static void cube_union_dii(unsigned &, unsigned &,
CORBA_Object_ptr, CORBA_Environment &);
// Global variables
-CORBA_ORB_ptr orb_ptr;
+const char* TAO_arg_ior = 0;
unsigned loop_count = 1;
-CORBA_Object_ptr objref = CORBA_Object::_nil();
-CORBA_Environment env;
int exit_later = 0;
// = TITLE
@@ -76,12 +74,7 @@ int parse_args(int argc, char *argv[])
case 'O': // stringified objref
{
- objref = orb_ptr->string_to_object (
- (CORBA_String)opts.optarg, env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "string2object");
- return 1;
- }
+ TAO_arg_ior = ACE_OS::strdup(opts.optarg);
}
continue;
@@ -106,258 +99,289 @@ int parse_args(int argc, char *argv[])
int
main (int argc, char *argv[])
- {
+{
+ CORBA_ORB_ptr orb_ptr;
+ CORBA_Object_ptr objref = CORBA_Object::_nil();
+ CORBA_Environment env;
#if defined (VXWORKS)
- // Work around VxWorks' lack of command line
+ // Work around VxWorks' lack of command line
- loop_count = 50;
- int dummy = 1;
- orb_ptr = CORBA_ORB_init (dummy, (char **)0, "internet", env);
- if (env.exception() != 0)
+ loop_count = 50;
+ int dummy = 1;
+ orb_ptr = CORBA_ORB_init (dummy, (char **)0, "internet", env);
+ if (env.exception() != 0)
{
- print_exception(env.exception(), "ORB initialization");
- return 1;
+ print_exception(env.exception(), "ORB initialization");
+ return 1;
}
- hostAdd( "mv2604d", "130.38.183.132" );
+ hostAdd( "mv2604d", "130.38.183.132" );
+
+ TAO_arg_ior = ACE_OS::strdup("iiop:1.0//mv2604d:1000/key0");
- objref = orb_ptr->string_to_object (
- (CORBA_String)"iiop:1.0//mv2604d:1000/key0", env);
#else
- orb_ptr = CORBA_ORB_init(argc, argv, "internet", env);
- if (env.exception() != 0)
+ orb_ptr = CORBA_ORB_init(argc, argv, "internet", env);
+ if (env.exception() != 0)
{
- print_exception(env.exception(), "ORB initialization");
- return 1;
+ print_exception(env.exception(), "ORB initialization");
+ return 1;
}
- //
- // Parse command line and verify parameters.
- //
- parse_args(argc, argv);
+ //
+ // Parse command line and verify parameters.
+ //
+ parse_args(argc, argv);
#endif
- if (CORBA_is_nil (objref) == CORBA_B_TRUE) {
- ACE_OS::fprintf (stderr, "%s: must identify non-null target objref\n",
- argv [0]);
- return 1;
+ if (TAO_arg_ior == 0)
+ ACE_ERROR_RETURN((LM_ERROR, "%s: must specify an object reference using -O <ior>\n", argv[0]), 1);
+
+ objref = orb_ptr->string_to_object ((CORBA_String)TAO_arg_ior, env);
+
+ ACE_OS::free(TAO_arg_ior);
+ TAO_arg_ior = 0;
+
+ if (env.exception () != 0)
+ {
+ print_exception (env.exception (), "string2object");
+ return 1;
}
- // Narrow the CORBA_Object reference to the stub object, checking
- // the type along the way using _is_a
- Cubit_ptr aCubit = Cubit::_narrow(objref);
+ if (CORBA_is_nil (objref) == CORBA_B_TRUE)
+ ACE_ERROR_RETURN((LM_ERROR, "%s: must identify non-null target objref\n", argv [0]), 1);
- //
- // Make the calls in a loop.
- //
- unsigned i;
- unsigned call_count, error_count;
+ // Narrow the CORBA_Object reference to the stub object, checking
+ // the type along the way using _is_a
+ Cubit_ptr aCubit = Cubit::_narrow(objref);
+ if (aCubit == 0)
+ ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to narrow object reference to a Cubit_ptr.\n"), 1);
- call_count = 0;
- error_count = 0;
+ //
+ // Make the calls in a loop.
+ //
+ unsigned i;
+ unsigned call_count, error_count;
- ACE_Time_Value before, after;
+ call_count = 0;
+ error_count = 0;
- before = ACE_OS::gettimeofday();
+ ACE_Time_Value before, after;
- for (i = 0; i < loop_count; i++) {
- //
- // Cube an octet.
- //
- CORBA_Octet arg_octet, ret_octet;
+ before = ACE_OS::gettimeofday();
+
+ for (i = 0; i < loop_count; i++)
+ {
+ //
+ // Cube an octet.
+ //
+ CORBA_Octet arg_octet, ret_octet;
- call_count++;
- ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env);
- if (env.exception () != 0) {
+ call_count++;
+ ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_octet");
error_count++;
- } else {
+ }
+ else
+ {
dmsg2 ("cube octet: %d --> %d\n", arg_octet, ret_octet);
arg_octet = arg_octet * arg_octet * arg_octet;
if (arg_octet != ret_octet) {
- ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n",
- (CORBA_Octet) func (i), ret_octet);
- error_count++;
+ ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n",
+ (CORBA_Octet) func (i), ret_octet);
+ error_count++;
}
- }
+ }
- //
- // Cube a short.
- //
- CORBA_Short arg_short, ret_short;
+ //
+ // Cube a short.
+ //
+ CORBA_Short arg_short, ret_short;
- call_count++;
- ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env);
- if (env.exception () != 0) {
+ call_count++;
+ ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_short");
error_count++;
- } else {
+ }
+ else
+ {
dmsg2 ("cube short: %d --> %d\n", arg_short, ret_short);
arg_short = arg_short * arg_short * arg_short;
- if (arg_short != ret_short) {
- ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n",
- (CORBA_Short) func (i), ret_short);
- error_count++;
- }
- }
+ if (arg_short != ret_short)
+ {
+ ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n",
+ (CORBA_Short) func (i), ret_short);
+ error_count++;
+ }
+ }
- //
- // Cube a long.
- //
- CORBA_Long arg_long, ret_long;
+ //
+ // Cube a long.
+ //
+ CORBA_Long arg_long, ret_long;
- call_count++;
- ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env);
- if (env.exception () != 0) {
+ call_count++;
+ ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_long");
error_count++;
- } else {
+ }
+ else
+ {
dmsg2 ("cube long: %d --> %d\n", arg_long, ret_long);
arg_long = arg_long * arg_long * arg_long;
if (arg_long != ret_long) {
- ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n",
- (CORBA_Long) func (i), ret_long);
- error_count++;
+ ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n",
+ (CORBA_Long) func (i), ret_long);
+ error_count++;
}
- }
+ }
- //
- // Cube a "struct" ...
- //
- Cubit_Many arg_struct, *ret_struct;
+ //
+ // Cube a "struct" ...
+ //
+ Cubit_Many arg_struct, *ret_struct;
- call_count++;
+ call_count++;
- arg_struct.l = func (i);
- arg_struct.s = func (i);
- arg_struct.o = func (i);
+ arg_struct.l = func (i);
+ arg_struct.s = func (i);
+ arg_struct.o = func (i);
- ret_struct = aCubit->Cubit_cube_struct (arg_struct, env);
- if (env.exception () != 0) {
+ ret_struct = aCubit->Cubit_cube_struct (arg_struct, env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_struct");
error_count++;
- } else {
+ }
+ else
+ {
dmsg ("cube struct ...");
arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l;
arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s;
arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o;
if (arg_struct.l != ret_struct->l
- || arg_struct.s != ret_struct->s
- || arg_struct.o != ret_struct->o) {
- ACE_OS::printf ("** cube_struct ERROR\n");
- error_count++;
- }
+ || arg_struct.s != ret_struct->s
+ || arg_struct.o != ret_struct->o)
+ {
+ ACE_OS::printf ("** cube_struct ERROR\n");
+ error_count++;
+ }
delete ret_struct;
- }
+ }
}
- after = ACE_OS::gettimeofday();
+ after = ACE_OS::gettimeofday();
- if (call_count > 0)
+ if (call_count > 0)
{
- if (error_count == 0)
- {
+ if (error_count == 0)
+ {
ACE_Time_Value diff = after - before;
unsigned long us = diff.sec() * 1000 * 1000 + diff.usec();
us /= call_count;
if (us > 0)
- ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t"
- "%ld calls/second\n",
- us / 1000, us % 1000,
- 1000000L / us);
- }
+ ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t"
+ "%ld calls/second\n",
+ us / 1000, us % 1000,
+ 1000000L / us);
+ }
- ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count);
+ ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count);
}
+ //
+ // Simple test for DII: call "cube_struct". (It's not timed
+ // since the copious mallocation of DII would bias numbers against
+ // typical stub-based calls.)
+ //
+ do {
//
- // Simple test for DII: call "cube_struct". (It's not timed
- // since the copious mallocation of DII would bias numbers against
- // typical stub-based calls.)
+ // Create the request ...
//
- do {
- //
- // Create the request ...
- //
- CORBA_Request_ptr req;
+ CORBA_Request_ptr req;
- req = objref->_request ((const CORBA_String) "cube_struct", env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "DII request create");
- break;
- }
-
- //
- // ... initialise the argument list and result ...
- //
- Cubit_Many arg, *result;
+ req = objref->_request ((const CORBA_String) "cube_struct", env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "DII request create");
+ break;
+ }
+
+ //
+ // ... initialise the argument list and result ...
+ //
+ Cubit_Many arg, *result;
- arg.o = 3; arg.l = 5; arg.s = -7;
+ arg.o = 3; arg.l = 5; arg.s = -7;
- CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE);
+ CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE);
- req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "DII request arg add");
- CORBA_release (req);
- break;
- }
+ req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "DII request arg add");
+ CORBA_release (req);
+ break;
+ }
- req->result ()->value ()
- ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "DII request result type");
- CORBA_release (req);
- break;
- }
-
- //
- // Make the invocation, verify the result
- //
- req->invoke ();
- if (req->env ()->exception () != 0) {
- print_exception (req->env ()->exception (), "DII invoke");
- CORBA_release (req);
- break;
- }
+ req->result ()->value ()
+ ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "DII request result type");
+ CORBA_release (req);
+ break;
+ }
+
+ //
+ // Make the invocation, verify the result
+ //
+ req->invoke ();
+ if (req->env ()->exception () != 0) {
+ print_exception (req->env ()->exception (), "DII invoke");
+ CORBA_release (req);
+ break;
+ }
- result = (Cubit_Many *) req->result ()->value ()->value ();
+ result = (Cubit_Many *) req->result ()->value ()->value ();
- if (result->o != 27 || result->l != 125 || result->s != -343)
- ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n");
- else
- dmsg ("DII cube_struct ... success!!");
+ if (result->o != 27 || result->l != 125 || result->s != -343)
+ ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n");
+ else
+ dmsg ("DII cube_struct ... success!!");
- CORBA_release (req);
+ CORBA_release (req);
- } while (0);
-
- //
- // Two more tests, using the "cube_union" function
- //
- cube_union_dii(call_count, error_count, objref, env);
- if (env.exception () != 0)
- error_count++;
+ } while (0);
+
+ //
+ // Two more tests, using the "cube_union" function
+ //
+ cube_union_dii(call_count, error_count, objref, env);
+ if (env.exception () != 0)
+ error_count++;
- cube_union_stub(i, call_count, error_count, objref, env);
- if (env.exception () != 0)
- error_count++;
+ cube_union_stub(i, call_count, error_count, objref, env);
+ if (env.exception () != 0)
+ error_count++;
- if (exit_later) {
- aCubit->Cubit_please_exit (env);
- dexc (env, "server, please ACE_OS::exit");
- }
+ if (exit_later) {
+ aCubit->Cubit_please_exit (env);
+ dexc (env, "server, please ACE_OS::exit");
+ }
- CORBA_release (objref);
+ CORBA_release (objref);
- return (error_count == 0) ? 0 : 1;
+ return (error_count == 0) ? 0 : 1;
}
diff --git a/TAO/IIOP/test/cubitS.cpp b/TAO/IIOP/test/cubitS.cpp
index 8e3e9864be9..b153b71db1b 100644
--- a/TAO/IIOP/test/cubitS.cpp
+++ b/TAO/IIOP/test/cubitS.cpp
@@ -16,10 +16,16 @@
#include "method_db.i"
#include "iiopobj.h"
+#if defined(CUBIT_USE_DYNAMIC_HASH)
TAO_Dynamic_Hash_OpTable tao_cubit_optable(7); // Dynamic Operation Table
+#else
+TAO_Linear_OpTable tao_cubit_optable(7);
+#endif
_skel_Cubit::_skel_Cubit(const char* obj_name)
{
+ const char* mn = "_skel_Cubit::_skel_Cubit()";
+
// Initialize Method Database
initialize_method_db (&tao_cubit_optable);
@@ -28,6 +34,14 @@ _skel_Cubit::_skel_Cubit(const char* obj_name)
IIOP_Object *data;
CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa();
+ if (oa == 0)
+ {
+ // We just have to assume that oa will be good, or we have to
+ // throw an exception. For now we "assume", but we'll
+ ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to locate a valid object adapter\n", mn));
+ return;
+ }
+
this->optable_ = &tao_cubit_optable;
data = new IIOP_Object(type_id);
@@ -41,14 +55,16 @@ _skel_Cubit::_skel_Cubit(const char* obj_name)
ACE_OS::memcpy (data->profile.object_key.buffer,
obj_name,
- data->profile.object_key.length);
+ data->profile.object_key.length+1);
this->set_parent(data);
this->sub_ = this;
- if (oa)
- oa->bind(data->profile.object_key, this);
-
+ if (oa->bind(data->profile.object_key, this) == -1)
+ {
+ ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to bind object to key '%s': %p\n", mn, data->profile.object_key.buffer));
+ return;
+ }
}
void
diff --git a/TAO/IIOP/test/method_db.i b/TAO/IIOP/test/method_db.i
index b567d09b7af..6b77cdf040a 100644
--- a/TAO/IIOP/test/method_db.i
+++ b/TAO/IIOP/test/method_db.i
@@ -58,7 +58,7 @@ static const method_db cubit_operations[] = {
};
-void initialize_method_db (TAO_Dynamic_Hash_OpTable *the_optable)
+void initialize_method_db (TAO_Operation_Table *the_optable)
{
for (int ndx = 0; ndx < 7; ndx++)
the_optable->bind(cubit_operations[ndx].opname,
diff --git a/TAO/IIOP/test/svr.cpp b/TAO/IIOP/test/svr.cpp
index 4afe2c62cd8..e4659d52c92 100644
--- a/TAO/IIOP/test/svr.cpp
+++ b/TAO/IIOP/test/svr.cpp
@@ -10,12 +10,14 @@
// Modified version of Cubit Example written by Sun Microsystems Inc.
// Modified by: Brian Mendel
-#include "cubit_i.h"
-#include <ace/Get_Opt.h>
+#include "ace/Get_Opt.h"
+#include "ace/Log_Msg.h"
#include "corba/orb.h"
-#include <corba/debug.h>
-#include <connect.h>
+#include "corba/debug.h"
+#include "connect.h"
+
+#include "cubit_i.h"
extern void
print_exception (const CORBA_Exception *, const char *, FILE *f=stdout);
@@ -27,7 +29,7 @@ int
main (int argc, char *argv[])
{
CORBA_Environment env;
- CORBA_Object_ptr obj;
+ CORBA_Object_ptr obj = 0;
CORBA_ORB_ptr orb_ptr;
CORBA_BOA_ptr oa_ptr;
CORBA_String key = (CORBA_String) "key0";
@@ -55,6 +57,9 @@ main (int argc, char *argv[])
// Initialize the Basic Object Adapter
oa_ptr = orb_ptr->BOA_init(argc, argv, "ROA");
+ if (oa_ptr == 0)
+ ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to initialize the BOA.\n"), 1);
+
// Create implementation object with user specified key
Cubit_i_ptr my_cubit = new Cubit_i(key);
@@ -63,14 +68,12 @@ main (int argc, char *argv[])
{
// Why are we getting the BOA_ptr from here when we've already
// got it above?
- CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa();
CORBA_OctetSeq obj_key;
obj_key.buffer = (CORBA_Octet *) key;
obj_key.length = obj_key.maximum = ACE_OS::strlen ((char *)key);
- if (oa)
- (void) oa->find(obj_key, obj);
-
+ if (oa_ptr->find(obj_key, obj) == -1)
+ ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 2);
//
// Stringify the objref we'll be implementing, and