diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-20 05:11:47 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-20 05:11:47 +0000 |
commit | 2c408e080f8fb72e72fbbf43d529faff471011cd (patch) | |
tree | a352ed9f55d048f43cf0202c53c5c5716b54bf3f | |
parent | c55a1223e913c285cb16ed10e3dd4e9a93c9ce39 (diff) | |
download | ATCD-2c408e080f8fb72e72fbbf43d529faff471011cd.tar.gz |
ChangeLogTag:Sat Jun 20 00:00:56 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
-rw-r--r-- | TAO/ChangeLog-98c | 36 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/start_services | 2 | ||||
-rw-r--r-- | TAO/tao/CDR.h | 78 | ||||
-rw-r--r-- | TAO/tao/CDR.i | 84 | ||||
-rw-r--r-- | TAO/tao/GIOP.cpp | 106 | ||||
-rw-r--r-- | TAO/tao/GIOP.h | 15 | ||||
-rw-r--r-- | TAO/tao/ORB.cpp | 37 | ||||
-rw-r--r-- | TAO/tao/ORB.i | 1 | ||||
-rw-r--r-- | TAO/tao/Principal.cpp | 38 | ||||
-rw-r--r-- | TAO/tao/Principal.h | 6 | ||||
-rw-r--r-- | TAO/tao/Sequence.h | 13 | ||||
-rw-r--r-- | TAO/tao/Sequence.i | 12 | ||||
-rw-r--r-- | TAO/tao/Server_Request.cpp | 43 | ||||
-rw-r--r-- | TAO/tao/corba.h | 13 | ||||
-rw-r--r-- | TAO/tao/decode.cpp | 6 |
15 files changed, 386 insertions, 104 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 18f9fb3b6cd..3ceb8014d49 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,39 @@ +Sat Jun 20 00:00:56 1998 Carlos O'Ryan <coryan@cs.wustl.edu> + + * tao/GIOP.h: + * tao/GIOP.cpp: + * tao/Server_Request.cpp: + Used compiled encoding and decoding for the GIOP and Request + headers, thus reducing the time on the critical path. + Removed a memory allocation on the server side by using ad-hoc + marshalling for the object key: it does not need to increase the + reference count on the CDR message block because its lifetime is + shorter that the CDR stream. + Added compiled marshalling methods for the ServiceContextList, + this is mostly a waste because the context list is always + empty. + + * tao/CDR.h: + * tao/CDR.i: + Enabled >> and << operators for CDR and basic types, added new + operators for strings. + + * tao/corba.h: + * tao/ORB.cpp: + Added operators to marshal octet sequences. + + * tao/decode.cpp: + Use the new replace() method to set the message block on octet + sequences. + + * tao/Sequence.h: + * tao/Sequence.i: + Added new replace() method that set the internal message block + in an octet sequence. + + * orbsvcs/tests/start_services: + Recommend the $USER instead of the $login macro for bash. + Fri Jun 19 21:30:22 1998 David L. Levine <levine@cs.wustl.edu> * TAO version 0.1.30 released. diff --git a/TAO/orbsvcs/tests/start_services b/TAO/orbsvcs/tests/start_services index 51c8b41f732..4f1afd22272 100755 --- a/TAO/orbsvcs/tests/start_services +++ b/TAO/orbsvcs/tests/start_services @@ -105,4 +105,4 @@ echo echo Note: if you will be running an application that uses the Naming Service, echo you might want to set the NameService environment variable, like this: echo 't/csh: % setenv NameService `cat /tmp/nameserviceior_'$login'`' -echo 'bash: $ export NameService=`cat /tmp/nameserviceior_'$login'`' +echo 'bash: $ export NameService=`cat /tmp/nameserviceior_'$USER'`' diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h index a0479464dfd..b150cb7a9f9 100644 --- a/TAO/tao/CDR.h +++ b/TAO/tao/CDR.h @@ -569,31 +569,59 @@ private: #if defined(__ACE_INLINE__) # include "tao/CDR.i" #else -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Boolean x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Octet x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Short x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::UShort x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Long x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::ULong x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::LongLong x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::ULongLong x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Float x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Double x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Char x); -extern TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::WChar x); - -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Boolean &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Octet &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Short &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::UShort &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Long &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::ULong &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::LongLong &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::ULongLong &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Float &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Double &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Char &x); -extern TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::WChar &x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Boolean x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Octet x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Short x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::UShort x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Long x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::ULong x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::LongLong x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::ULongLong x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Float x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Double x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::Char x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + CORBA::WChar x); +extern TAO_Export TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, + const CORBA::Char* x); + +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Boolean &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Octet &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Short &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::UShort &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Long &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::ULong &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::LongLong &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::ULongLong &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Float &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Double &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::Char &x); +extern TAO_Export TAO_InputCDR& operator>> (TAO_InputCDR& cdr, + CORBA::WChar &x); +extern TAO_Export TAO_InputCDR& operator<< (TAO_InputCDR& cdr, + CORBA::Char*& x); #endif /* __ACE_INLINE */ #endif /* TAO_CDR_H */ diff --git a/TAO/tao/CDR.i b/TAO/tao/CDR.i index d944cb700ef..f01c4c92c3c 100644 --- a/TAO/tao/CDR.i +++ b/TAO/tao/CDR.i @@ -614,12 +614,12 @@ TAO_InputCDR::rd_ptr (void) // **************************************************************** // TODO: Use the CORBA_* types when they become available. -#if 0 #if defined (ACE_HAS_BOOL) ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Boolean x) { - cdr.write_boolean (x); + if (cdr.good_bit ()) + cdr.write_boolean (x); return cdr; } #endif /* ACE_HAS_BOOL */ @@ -627,70 +627,88 @@ operator<< (TAO_OutputCDR& cdr, CORBA::Boolean x) ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Octet x) { - cdr.write_octet (x); + if (cdr.good_bit ()) + cdr.write_octet (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Short x) { - cdr.write_short (x); + if (cdr.good_bit ()) + cdr.write_short (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::UShort x) { - cdr.write_short (x); + if (cdr.good_bit ()) + cdr.write_short (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Long x) { - cdr.write_long (x); + if (cdr.good_bit ()) + cdr.write_long (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::ULong x) { - cdr.write_long (x); + if (cdr.good_bit ()) + cdr.write_long (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::LongLong x) { - cdr.write_longlong (x); + if (cdr.good_bit ()) + cdr.write_longlong (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::ULongLong x) { - cdr.write_ulonglong (x); + if (cdr.good_bit ()) + cdr.write_ulonglong (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Float x) { - cdr.write_float (x); + if (cdr.good_bit ()) + cdr.write_float (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Double x) { - cdr.write_double (x); + if (cdr.good_bit ()) + cdr.write_double (x); return cdr; } ACE_INLINE TAO_OutputCDR& operator<< (TAO_OutputCDR& cdr, CORBA::Char x) { - cdr.write_char (x); + if (cdr.good_bit ()) + cdr.write_char (x); + return cdr; +} + +ACE_INLINE TAO_OutputCDR& +operator<< (TAO_OutputCDR& cdr, const CORBA::Char* x) +{ + if (cdr.good_bit ()) + cdr.write_string (x); return cdr; } @@ -698,7 +716,8 @@ operator<< (TAO_OutputCDR& cdr, CORBA::Char x) ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Boolean &x) { - cdr.read_boolean (x); + if (cdr.good_bit ()) + cdr.read_boolean (x); return cdr; } #endif /* ACE_HAS_BOOL */ @@ -706,73 +725,90 @@ operator>> (TAO_InputCDR& cdr, CORBA::Boolean &x) ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Octet &x) { - cdr.read_octet (x); + if (cdr.good_bit ()) + cdr.read_octet (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Short &x) { - cdr.read_short (x); + if (cdr.good_bit ()) + cdr.read_short (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::UShort &x) { - cdr.read_ushort (x); + if (cdr.good_bit ()) + cdr.read_ushort (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Long &x) { - cdr.read_long (x); + if (cdr.good_bit ()) + cdr.read_long (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::ULong &x) { - cdr.read_ulong (x); + if (cdr.good_bit ()) + cdr.read_ulong (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::LongLong &x) { - cdr.read_longlong (x); + if (cdr.good_bit ()) + cdr.read_longlong (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::ULongLong &x) { - cdr.read_ulonglong (x); + if (cdr.good_bit ()) + cdr.read_ulonglong (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Float &x) { - cdr.read_float (x); + if (cdr.good_bit ()) + cdr.read_float (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Double &x) { - cdr.read_double (x); + if (cdr.good_bit ()) + cdr.read_double (x); return cdr; } ACE_INLINE TAO_InputCDR& operator>> (TAO_InputCDR& cdr, CORBA::Char &x) { - cdr.read_char (x); + if (cdr.good_bit ()) + cdr.read_char (x); + return cdr; +} + +ACE_INLINE TAO_InputCDR& +operator>> (TAO_InputCDR& cdr, CORBA::Char*&x) +{ + if (cdr.good_bit ()) + cdr.read_string (x); return cdr; } -#endif /* 0 */ // *************************************************************************** // We must define these methods here because they use the "read_*" inlined diff --git a/TAO/tao/GIOP.cpp b/TAO/tao/GIOP.cpp index 1bdc053d863..52cf567f563 100644 --- a/TAO/tao/GIOP.cpp +++ b/TAO/tao/GIOP.cpp @@ -132,6 +132,52 @@ TAO_GIOP::dump_msg (const char *label, } } +TAO_OutputCDR& +operator<<(TAO_OutputCDR& cdr, const TAO_GIOP_ServiceContext& x) +{ + if (cdr.good_bit ()) + { + cdr << x.context_id + << x.context_data; + } + return cdr; +} + +TAO_InputCDR& +operator>>(TAO_InputCDR& cdr, TAO_GIOP_ServiceContext& x) +{ + if (cdr.good_bit ()) + { + cdr >> x.context_id + >> x.context_data; + } + return cdr; +} + +TAO_OutputCDR& +operator<<(TAO_OutputCDR& cdr, const TAO_GIOP_ServiceContextList& x) +{ + CORBA::ULong length = x.length (); + cdr.write_ulong (length); + for (CORBA::ULong i = 0; i < length && cdr.good_bit (); ++i) + cdr << x[i]; + return cdr; +} + +TAO_InputCDR& +operator>>(TAO_InputCDR& cdr, TAO_GIOP_ServiceContextList& x) +{ + CORBA::ULong length; + cdr.read_ulong (length); + if (cdr.good_bit ()) + { + x.length (length); + for (CORBA::ULong i = 0; i < length && cdr.good_bit (); ++i) + cdr >> x[i]; + } + return cdr; +} + // @@ TODO: this is a good candidate for an ACE routine, even more, // all the code to write a Message_Block chain could be encapsulated // in ACE. @@ -622,8 +668,6 @@ TAO_GIOP_Invocation::start (CORBA::Environment &env) { ACE_FUNCTION_TIMEPROBE (TAO_GIOP_INVOCATION_START_ENTER); - const TAO_opaque *key; - // First try to bind to the appropriate address. We do that here // since we may get forwarded to a different objref in the course of // any given call, with new start () call each time. It's not @@ -645,10 +689,8 @@ TAO_GIOP_Invocation::start (CORBA::Environment &env) // Determine the object key and the address to which we'll need a // connection. - ACE_INET_Addr *server_addr_p = 0; - - key = &data_->profile.object_key; - server_addr_p = &data_->profile.object_addr (); + ACE_INET_Addr *server_addr_p = + &data_->profile.object_addr (); if (server_addr_p == 0) { @@ -735,30 +777,15 @@ TAO_GIOP_Invocation::start (CORBA::Environment &env) static CORBA::Principal_ptr anybody = 0; static TAO_GIOP_ServiceContextList svc_ctx; // all zeroes - if (this->out_stream_.encode (TC_ServiceContextList, 0, &svc_ctx, env) - != CORBA::TypeCode::TRAVERSE_CONTINUE) - return; - - if (!this->out_stream_.write_ulong (this->my_request_id_) - || !this->out_stream_.write_boolean (this->do_rsvp_)) - { - env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_NO)); - return; - } + this->out_stream_ << svc_ctx; + this->out_stream_.write_ulong (this->my_request_id_); + this->out_stream_.write_boolean (this->do_rsvp_); + this->out_stream_ << this->data_->profile.object_key; + this->out_stream_.write_string (this->opname_); + this->out_stream_ << anybody; - if (this->out_stream_.encode (TC_opaque, - key, - 0, - env) != CORBA::TypeCode::TRAVERSE_CONTINUE - || this->out_stream_.encode (CORBA::_tc_string, - &opname_, - 0, - env) != CORBA::TypeCode::TRAVERSE_CONTINUE - || this->out_stream_.encode (CORBA::_tc_Principal, - &anybody, - 0, - env) != CORBA::TypeCode::TRAVERSE_CONTINUE) - return; // pass the exception through.... + if (!this->out_stream_.good_bit ()) + env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_NO)); ACE_TIMEPROBE (TAO_GIOP_INVOCATION_START_REQUEST_HDR); } @@ -943,9 +970,10 @@ TAO_GIOP_Invocation::invoke (CORBA::ExceptionList &exceptions, CORBA::ULong request_id; CORBA::ULong reply_status; // TAO_GIOP_ReplyStatusType - if (this->inp_stream_.decode (TC_ServiceContextList, &reply_ctx, 0, env) - != CORBA::TypeCode::TRAVERSE_CONTINUE) + this->inp_stream_ >> reply_ctx; + if (!this->inp_stream_.good_bit ()) { + env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_NO)); TAO_GIOP::send_error (this->handler_); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -1319,10 +1347,11 @@ TAO_GIOP_Invocation::invoke (TAO_Exception_Data *excepts, CORBA::ULong request_id; CORBA::ULong reply_status; // TAO_GIOP_ReplyStatusType - if (this->inp_stream_.decode (TC_ServiceContextList, &reply_ctx, 0, env) - != CORBA::TypeCode::TRAVERSE_CONTINUE) + this->inp_stream_ >> reply_ctx; + if (!this->inp_stream_.good_bit ()) { TAO_GIOP::send_error (this->handler_); + env.exception (new CORBA::MARSHAL (CORBA::COMPLETED_NO)); return TAO_GIOP_SYSTEM_EXCEPTION; } @@ -1530,6 +1559,7 @@ TAO_GIOP::start_message (TAO_GIOP::Message_Type type, // if (msg.size () < TAO_GIOP_HEADER_LEN) // return CORBA::B_FALSE; +#if 0 msg.write_octet ('G'); msg.write_octet ('I'); msg.write_octet ('O'); @@ -1539,6 +1569,16 @@ TAO_GIOP::start_message (TAO_GIOP::Message_Type type, msg.write_octet (TAO_GIOP_MessageHeader::MY_MINOR); msg.write_octet (TAO_ENCAP_BYTE_ORDER); +#else + static CORBA::Octet header[] = { + 'G', 'I', 'O', 'P', + TAO_GIOP_MessageHeader::MY_MAJOR, + TAO_GIOP_MessageHeader::MY_MINOR, + TAO_ENCAP_BYTE_ORDER + }; + static int header_size = sizeof(header)/sizeof(header[0]); + msg.write_octet_array (header, header_size); +#endif msg.write_octet (type); // Write a dummy <size> later it is set to the right value... diff --git a/TAO/tao/GIOP.h b/TAO/tao/GIOP.h index 2ed2c771c6a..21c564e6f3b 100644 --- a/TAO/tao/GIOP.h +++ b/TAO/tao/GIOP.h @@ -35,6 +35,9 @@ #if !defined (TAO_GIOP_H) # define TAO_GIOP_H +class TAO_Export TAO_InputCDR; +class TAO_Export TAO_OuputCDR; + // namespace TAO_IOP // Assigned Protocol/Profile tag values. ORB protcols may be uniquely @@ -186,6 +189,18 @@ typedef TAO_Unbounded_Sequence<TAO_GIOP_ServiceContext> extern CORBA::TypeCode_ptr TC_ServiceContextList; +extern TAO_Export TAO_OutputCDR& +operator<<(TAO_OutputCDR&, const TAO_GIOP_ServiceContext&); + +extern TAO_Export TAO_InputCDR& +operator>>(TAO_InputCDR&, TAO_GIOP_ServiceContext&); + +extern TAO_Export TAO_OutputCDR& +operator<<(TAO_OutputCDR&, const TAO_GIOP_ServiceContextList&); + +extern TAO_Export TAO_InputCDR& +operator>>(TAO_InputCDR&, TAO_GIOP_ServiceContextList&); + // = Reply headers enum TAO_GIOP_ReplyStatusType diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 5c61403f8f7..a3b529ef6cb 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -766,6 +766,43 @@ CORBA::ORB_init (int &argc, return TAO_ORB_Core_instance()->orb (); } +// ************************************************************* +// Inline operators for TAO_opaque encoding and decoding +// ************************************************************* + +TAO_OutputCDR& +operator<<(TAO_OutputCDR& cdr, const TAO_opaque& x) +{ + CORBA::ULong length = x.length (); + cdr.write_ulong (length); +#if !defined (TAO_NO_COPY_OCTET_SEQUENCES) + cdr.write_octet_array (x.get_buffer (), length); +#else + if (x.mb_ == 0) + cdr.write_octet_array (x.get_buffer (), length); + else + cdr.write_octet_array_mb (x.mb_); +#endif /* TAO_NO_COPY_OCTET_SEQUENCES */ + return cdr; +} + +TAO_InputCDR& +operator>>(TAO_InputCDR& cdr, TAO_opaque& x) +{ + CORBA::ULong length; + cdr.read_ulong (length); +#if !defined (TAO_NO_COPY_OCTET_SEQUENCES) + x.length (length); + cdr.read_octet_array (x.get_buffer (), length); +#else + x.replace (length, cdr.start ()); + cdr.skip_bytes (length); +#endif /* TAO_NO_COPY_OCTET_SEQUENCES */ + return cdr; +} + +// **************************************************************** + #define TAO_HASH_ADDR ACE_Hash_Addr<ACE_INET_Addr> #define TAO_RECYCLABLE_ADDR ACE_Recyclable<TAO_HASH_ADDR> #define TAO_HASH_RECYCLABLE_ADDR ACE_Hash_Recyclable<TAO_HASH_ADDR> diff --git a/TAO/tao/ORB.i b/TAO/tao/ORB.i index 334f220ca98..a29a631feae 100644 --- a/TAO/tao/ORB.i +++ b/TAO/tao/ORB.i @@ -371,3 +371,4 @@ CORBA_ORB_out::operator-> (void) { return this->ptr_; } + diff --git a/TAO/tao/Principal.cpp b/TAO/tao/Principal.cpp index 6e3748730a3..5798da4ad93 100644 --- a/TAO/tao/Principal.cpp +++ b/TAO/tao/Principal.cpp @@ -6,6 +6,10 @@ #include "tao/corba.h" +#if !defined (__ACE_INLINE__) +#include "tao/Principal.i" +#endif /* __ACE_INLINE__ */ + void CORBA::release (CORBA::Principal_ptr principal) { @@ -45,3 +49,37 @@ CORBA_Principal::Release (void) delete this; return 0; } + +TAO_OutputCDR& +operator<< (TAO_OutputCDR& cdr, CORBA_Principal* x) +{ + if (x != 0) + { + CORBA::ULong length = x->id.length (); + cdr.write_long (length); + cdr.write_octet_array (x->id.get_buffer (), length); + } + else + { + cdr.write_ulong (0); + } + return cdr; +} + +TAO_InputCDR& +operator>> (TAO_InputCDR& cdr, CORBA_Principal*& x) +{ + CORBA::ULong length; + cdr.read_ulong (length); + if (length == 0 || !cdr.good_bit ()) + { + x = 0; + } + else + { + ACE_NEW_RETURN (x, CORBA::Principal, cdr); + x->id.length (length); + cdr.read_octet_array (x->id.get_buffer (), length); + } + return cdr; +} diff --git a/TAO/tao/Principal.h b/TAO/tao/Principal.h index 0de5dde1404..690e6e666a4 100644 --- a/TAO/tao/Principal.h +++ b/TAO/tao/Principal.h @@ -57,4 +57,10 @@ private: #endif /* __GNUG__ */ }; +extern TAO_Export TAO_OutputCDR& +operator<<(TAO_OutputCDR&, CORBA_Principal*); + +extern TAO_Export TAO_InputCDR& +operator>>(TAO_InputCDR&, CORBA_Principal*&); + #endif /* TAO_PRINCIPAL_H */ diff --git a/TAO/tao/Sequence.h b/TAO/tao/Sequence.h index 763319583ed..dd92c0d5616 100644 --- a/TAO/tao/Sequence.h +++ b/TAO/tao/Sequence.h @@ -435,9 +435,22 @@ public: // consistent with the CORBA calling semantics, return values are // owned by the caller). + void replace (CORBA::ULong length, const ACE_Message_Block* mb); + // Replaces the current buffer with <mb>, using only <length> bytes. + // It takes a duplicate of <mb>. + + friend TAO_OutputCDR& + operator <<(TAO_OutputCDR&, + const TAO_Unbounded_Sequence<CORBA::Octet>&); + + friend TAO_InputCDR& + operator <<(TAO_InputCDR&, + TAO_Unbounded_Sequence<CORBA::Octet>&); + private: ACE_Message_Block* mb_; }; + #endif /* defined (TAO_NO_COPY_OCTET_SEQUENCES) */ // **************************************************************** diff --git a/TAO/tao/Sequence.i b/TAO/tao/Sequence.i index 9a61af4d15f..ca46ba1dd34 100644 --- a/TAO/tao/Sequence.i +++ b/TAO/tao/Sequence.i @@ -290,4 +290,16 @@ TAO_Unbounded_Sequence<CORBA::Octet>::mb (void) const return ACE_Message_Block::duplicate (this->mb_); } +ACE_INLINE void +TAO_Unbounded_Sequence<CORBA::Octet>::replace (CORBA::ULong length, + const ACE_Message_Block* mb) +{ + this->_deallocate_buffer (); + this->mb_ = ACE_Message_Block::duplicate (mb); + this->buffer_ = this->mb_->rd_ptr (); + this->maximum_ = length; + this->length_ = length; + this->release_ = CORBA::B_FALSE; +} + #endif /* defined (TAO_NO_COPY_OCTET_SEQUENCES) */ diff --git a/TAO/tao/Server_Request.cpp b/TAO/tao/Server_Request.cpp index f64b038e4ec..e9b3e276f90 100644 --- a/TAO/tao/Server_Request.cpp +++ b/TAO/tao/Server_Request.cpp @@ -79,8 +79,6 @@ IIOP_ServerRequest::IIOP_ServerRequest (TAO_InputCDR &input, { ACE_FUNCTION_TIMEPROBE (TAO_SERVER_REQUEST_START); - CORBA::Boolean hdr_status; - // Tear out the service context ... we currently ignore it, but it // should probably be passed to each ORB service as appropriate // (e.g. transactions, security). @@ -90,25 +88,40 @@ IIOP_ServerRequest::IIOP_ServerRequest (TAO_InputCDR &input, // environment. It may be required even when using IPSEC security // infrastructure. - hdr_status = input.decode (TC_ServiceContextList, - &this->service_info_, - 0, - env); + input >> this->service_info_; + CORBA::Boolean hdr_status = input.good_bit (); // Get the rest of the request header ... hdr_status = hdr_status && input.read_ulong (this->request_id_); hdr_status = hdr_status && input.read_boolean (this->response_expected_); + +#if defined (TAO_COPY_OBJKEY) + // Actually it is not a copy, but it increases a reference count and + // thus allocates more memory. hdr_status = hdr_status && input.decode (TC_opaque, &this->object_key_, 0, env); +#else + // We use ad-hoc demarshalling here: there is no need to increase + // the reference count on the CDR message block, because this key + // will not outlive the request (or the message block). + + CORBA::Long key_length; + hdr_status = hdr_status && input.read_long (key_length); + if (hdr_status) + { + this->object_key_.replace (key_length, key_length, + (CORBA::Octet*)input.rd_ptr (), + CORBA::B_FALSE); + input.skip_bytes (key_length); + } +#endif + #if !defined (TAO_COPY_OPNAME) CORBA::Long length; - hdr_status = hdr_status && input.decode (CORBA::_tc_long, - &length, - 0, - env); + hdr_status = hdr_status && input.read_long (length); if (hdr_status) { this->operation_ = input.rd_ptr (); @@ -120,10 +133,12 @@ IIOP_ServerRequest::IIOP_ServerRequest (TAO_InputCDR &input, 0, env); #endif - hdr_status = hdr_status && input.decode (CORBA::_tc_Principal, - &this->requesting_principal_, - 0, - env); + + if (hdr_status) + { + input >> this->requesting_principal_; + hdr_status = input.good_bit (); + } if (!hdr_status) env.exception (new CORBA::COMM_FAILURE (CORBA::COMPLETED_NO)); diff --git a/TAO/tao/corba.h b/TAO/tao/corba.h index c6c9ed2fddb..45388b97758 100644 --- a/TAO/tao/corba.h +++ b/TAO/tao/corba.h @@ -140,6 +140,9 @@ class CORBA_String_var; class CORBA_ExceptionList; +class TAO_InputCDR; +class TAO_OuputCDR; + // enum values defined in nvlist.hh, bitwise ORed. typedef u_int CORBA_Flags; @@ -152,8 +155,8 @@ typedef void (*TAO_Skeleton)(CORBA_ServerRequest &, // NOTE: stub APIs are nonportable, and must be explicitly #included // by code emitted from an IDL compiler. -#if defined (_MSC_VER) -# pragma pack (pop) // VC++, goes back to other padding rules +#if defined (_MSC_VER) +#pragma pack (pop) // VC++, goes back to other padding rules #endif /* _MSC_VER */ // Alignment macros @@ -165,6 +168,12 @@ typedef void (*TAO_Skeleton)(CORBA_ServerRequest &, typedef TAO_Unbounded_Sequence<CORBA::Octet> TAO_opaque; extern CORBA::TypeCode_ptr TC_opaque; +extern TAO_Export TAO_OutputCDR& +operator<<(TAO_OutputCDR&, const TAO_opaque&); + +extern TAO_Export TAO_InputCDR& +operator>>(TAO_InputCDR&, TAO_opaque&); + #include "tao/Exception.h" #include "tao/Any.h" diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index 4f0312507b8..6e188b5fac9 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -1082,11 +1082,7 @@ TAO_Marshal_Sequence::decode (CORBA::TypeCode_ptr tc, { TAO_Unbounded_Sequence<CORBA::Octet>* seq2 = ACE_dynamic_cast(TAO_Unbounded_Sequence<CORBA::Octet>*, seq); - seq2->_deallocate_buffer (); - seq2->mb_ = stream->start ()->duplicate (); - seq2->buffer_ = seq2->mb_->rd_ptr (); - seq2->maximum_ = bounds; - seq2->length_ = bounds; + seq2->replace (bounds, stream->start ()); stream->skip_bytes (bounds); return CORBA::TypeCode::TRAVERSE_CONTINUE; } |