diff options
author | bala <balanatarajan@users.noreply.github.com> | 2000-04-01 00:44:12 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2000-04-01 00:44:12 +0000 |
commit | 66fca9e66eac745f65ccd9117965a9556482747c (patch) | |
tree | 6ddd82ddff950c5cb4daf88323b61e7c0c635695 | |
parent | 1c5854d46669e725c080ab86725c7f59dae8ee6d (diff) | |
download | ATCD-66fca9e66eac745f65ccd9117965a9556482747c.tar.gz |
ChangeLogTag: Fri Mar 31 18:36:34 2000 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 28 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Accept_State.cpp | 369 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Accept_State.h | 74 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Accept_State.i | 4 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Acceptors.cpp | 54 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Acceptors.h | 17 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Acceptors.i | 20 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Base.cpp | 8 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Base.h | 5 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Connectors.cpp | 218 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Connectors.h | 67 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Lite.cpp | 181 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Lite.h | 26 | ||||
-rw-r--r-- | TAO/tao/GIOP_Message_Lite.i | 23 | ||||
-rw-r--r-- | TAO/tao/GIOP_Server_Request.cpp | 182 | ||||
-rw-r--r-- | TAO/tao/GIOP_Server_Request.h | 2 | ||||
-rw-r--r-- | TAO/tao/GIOP_Utils.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/GIOP_Utils.h | 2 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connect.h | 1 | ||||
-rw-r--r-- | TAO/tao/Pluggable_Messaging.h | 15 | ||||
-rw-r--r-- | TAO/tao/Pluggable_Messaging_Utils.h | 18 | ||||
-rw-r--r-- | TAO/tao/Pluggable_Messaging_Utils.i | 24 |
22 files changed, 1111 insertions, 237 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 6420bda81ca..8185d2e4880 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,31 @@ +Fri Mar 31 18:36:34 2000 Balachandran Natarajan <bala@cs.wustl.edu> + + * tao/GIOP_Message_Accept_State.cpp (write_reply_header): + * tao/GIOP_Message_Accept_State.h: + * tao/GIOP_Message_Accept_State.i: + * tao/GIOP_Message_Acceptors.cpp: + * tao/GIOP_Message_Acceptors.h: + * tao/GIOP_Message_Acceptors.i: + * tao/GIOP_Message_Base.h: + * tao/GIOP_Message_Base.cpp: + * tao/GIOP_Message_Connectors.cpp: + * tao/GIOP_Message_Connectors.h: + * tao/GIOP_Message_Lite.cpp: + * tao/GIOP_Message_Lite.h: + * tao/GIOP_Server_Request.h: + * tao/GIOP_Server_Request.cpp: + * tao/GIOP_Utils.cpp: + * tao/GIOP_Utils.h: + * tao/IIOP_Connect.h: + * tao/Pluggable_Messaging.h: + * tao/Pluggable_Messaging_Utils.h: + * tao/Pluggable_Messaging_Utils.i: Added a new method by name + write_reply_header () to the pluggable messaging + interface. Changes in other files are for implementation and + proper usage of this method within our GIOP + implementation. This is in line with Carlos's suggestion. I have + not got around to address his other comments. + Fri Mar 31 08:15:39 2000 David L. Levine <levine@cs.wustl.edu> * TAO_IDL/be/be_visitor_interface/smart_proxy_ch.cpp: diff --git a/TAO/tao/GIOP_Message_Accept_State.cpp b/TAO/tao/GIOP_Message_Accept_State.cpp index 5345a6c414a..0e3c0e9ab5a 100644 --- a/TAO/tao/GIOP_Message_Accept_State.cpp +++ b/TAO/tao/GIOP_Message_Accept_State.cpp @@ -5,15 +5,93 @@ #include "tao/debug.h" #include "tao/GIOP_Server_Request.h" #include "tao/GIOP_Utils.h" +//#include "tao/CDR.h" +#include "tao/Pluggable_Messaging_Utils.h" +#include "tao/NVList.h" + ACE_RCSID(tao, GIOP_Message_Accept_State, "$Id$") + #if !defined (__ACE_INLINE__) # include "tao/GIOP_Message_Accept_State.i" #endif /* __ACE_INLINE__ */ + +CORBA::Boolean +TAO_GIOP_Message_Accept_State::marshal_svc_ctx (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply) +{ + // Write the service context list +#if (TAO_HAS_MINIMUM_CORBA == 1) + output << reply.service_context_notowned (); +#else + if (reply.params_ == 0) + { + output << reply.service_context_notowned (); + } + else + { + // If lazy evaluation is enabled then we are going to insert an + // extra node at the end of the service context list, just to + // force the appropiate padding. + // But first we take it out any of them.. + CORBA::ULong count = 0; + IOP::ServiceContextList &svc_ctx = + reply.service_context_notowned (); + CORBA::ULong l = svc_ctx.length (); + CORBA::ULong i; + for (i = 0; i != l; ++i) + { + if (svc_ctx[i].context_id == TAO_SVC_CONTEXT_ALIGN) + continue; + count++; + } + // Now increment it to account for the last dummy one... + count++; + + // Now marshal the rest of the service context objects + output << count; + for (i = 0; i != l; ++i) + { + if (svc_ctx[i].context_id == TAO_SVC_CONTEXT_ALIGN) + continue; + output << svc_ctx[i]; + } + } +#endif /* TAO_HAS_MINIMUM_CORBA */ + return 1; +} + + +void +TAO_GIOP_Message_Accept_State::marshal_reply_status (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply) +{ + switch (reply.reply_status_) + { + case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION: + output.write_ulong (TAO_GIOP_NO_EXCEPTION); + break; + case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD: + output.write_ulong (TAO_GIOP_LOCATION_FORWARD); + break; + case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION: + output.write_ulong (TAO_GIOP_SYSTEM_EXCEPTION); + break; + case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION: + output.write_ulong (TAO_GIOP_USER_EXCEPTION); + break; + default: + // Some other specifc exception + output.write_ulong (reply.reply_status_); + break; + } +} + + //////////////////////////////////////////////////////////////////////////////// -// TAO_GIOP_Message_Accept_State_11 methods +// TAO_GIOP_Message_Accept_State_10 methods //////////////////////////////////////////////////////////////////////////////// int TAO_GIOP_Message_Accept_State_10:: @@ -124,21 +202,93 @@ TAO_GIOP_Message_Accept_State_10:: CORBA::Boolean TAO_GIOP_Message_Accept_State_10:: write_reply_header (TAO_OutputCDR &output, - CORBA::ULong request_id) + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) { - // create and write a dummy context - IOP::ServiceContextList resp_ctx; - resp_ctx.length (0); - output << resp_ctx; - // Write the request ID - output.write_ulong (request_id); + this->marshal_svc_ctx (output, + reply); +#if (TAO_HAS_MINIMUM_CORBA == 0) + if (reply.params_ != 0) + { + // @@ Much of this code is GIOP 1.1 specific and should be + ptr_arith_t target = + reply.params_->_tao_target_alignment (); + + ptr_arith_t current = + ptr_arith_t (output.current_alignment ()) % ACE_CDR::MAX_ALIGNMENT; + + CORBA::ULong pad = 0; + if (target == 0) + { + // We want to generate adequate padding to start the request + // id on a 8 byte boundary, two cases: + // - If the dummy tag starts on a 4 byte boundary and the + // dummy sequence has 0 elements then we have: + // 4:tag 8:sequence_length 4:sequence_body 4:request_id + // 8:payload + // - If the dummy tag starts on an 8 byte boundary, with 4 + // elements we get: + // 8:tag 4:sequence_length 8:sequence_body 4:request_id + // 8:payload + if (current != 0 && current <= ACE_CDR::LONG_ALIGN) + { + pad = 4; + } + } + else if (target != ACE_CDR::LONG_ALIGN) + { + // The situation reverses, we want to generate adequate + // padding to start the request id on a 4 byte boundary, two + // cases: + // - If the dummy tag starts on a 4 byte boundary and the + // dummy sequence has 4 elements then we have: + // 4:tag 8:sequence_length 4:sequence_body 8:request_id + // 4:payload + // - If the dummy tag starts on an 8 byte boundary, with 0 + // elements we get: + // 8:tag 4:sequence_length 8:sequence_body 8:request_id + // 4:payload + if (current > ACE_CDR::LONG_ALIGN) + { + pad = 4; + } + } + else if (target == ACE_CDR::MAX_ALIGNMENT) + { + pad = 0; + } + else + { + // <target> can only have the values above + ACE_THROW_RETURN (CORBA::MARSHAL (), + 0); + } + + output << CORBA::ULong (TAO_SVC_CONTEXT_ALIGN); + output << pad; + for (CORBA::ULong j = 0; j != pad; ++j) + { + output << ACE_OutputCDR::from_octet(0); + } + } +#endif /* TAO_HAS_MINIMUM_CORBA */ + + // Write the request ID + output.write_ulong (reply.request_id_); + // Write the reply status + this->marshal_reply_status (output, + reply); + ACE_UNUSED_ARG (ACE_TRY_ENV); return 1; } + + int TAO_GIOP_Message_Accept_State_10:: parse_locate_header (TAO_GIOP_Locate_Request_Header &request) @@ -164,11 +314,15 @@ TAO_GIOP_Message_Accept_State_10:: GIOP::TargetAddress &target = request.target_address (); // Put this object key in the target_adderss + // This has a "new" in it. Need to change that to something more + // efficient target.object_key (object_key); return hdr_status ? 0 : -1; } + + CORBA::Boolean TAO_GIOP_Message_Accept_State_10:: write_locate_reply_mesg (TAO_OutputCDR &output, @@ -201,12 +355,16 @@ TAO_GIOP_Message_Accept_State_10::major_version (void) return (CORBA::Octet) 1; } + + CORBA::Octet TAO_GIOP_Message_Accept_State_10::minor_version (void) { return (CORBA::Octet) 0; } + + ///////////////////////////////////////////////////// // TAO_GIOP_Message_Accept_State_11 ///////////////////////////////////////////////////// @@ -216,3 +374,198 @@ TAO_GIOP_Message_Accept_State_11::minor_version (void) { return 1; } + + + +//////////////////////////////////////////////////////////////////////////////// +// TAO_GIOP_Message_Accept_State_12 methods +//////////////////////////////////////////////////////////////////////////////// + +// The methods below are not complete +int +TAO_GIOP_Message_Accept_State_12:: + parse_request_header (TAO_GIOP_ServerRequest &request) +{ + + // Get the input CDR in the request class + TAO_InputCDR& input = request.incoming (); + + CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit (); + + CORBA::ULong req_id; + // Get the rest of the request header ... + hdr_status = hdr_status && input.read_ulong (req_id); + + request.request_id (req_id); + + CORBA::Octet response_flags; + hdr_status = hdr_status && input.read_octet (response_flags); + + // Need to work around the hacks + request.response_expected ((response_flags != 0)); + + // The high bit of the octet has been set if the SyncScope policy + // value is SYNC_WITH_SERVER. This is a temporary hack until all + // of GIOP 1.2 is in place. Then we can check the version in the + // message header instead. + request.sync_with_server ((response_flags == 129)); + + hdr_status = hdr_status && this->unmarshall_target_addr (request, + input); + ACE_CString operation_name; + if (input.char_translator () == 0) + { + CORBA::ULong length = 0; + hdr_status = hdr_status && input.read_ulong (length); + if (hdr_status) + { + // Do not include NULL character at the end. + // @@ This is not getting demarshaled using the codeset + // translators! + operation_name.set (input.rd_ptr (), + length - 1, + 0); + request.operation (operation_name); + hdr_status = input.skip_bytes (length); + } + } + else + { + // @@ We could optimize for this case too, i.e. do in-place + // demarshaling of the string... But there is an issue + // pending on the OMG as to whether the operation should be + // sent in the connection negotiated codeset or always in + // ISO8859-1. + CORBA::String_var tmp; + hdr_status = hdr_status && input.read_string (tmp.inout ()); + operation_name.set (tmp._retn (), 1); + request.operation (operation_name); + } + + // 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). + // + // NOTE: As security support kicks in, this is a good place to + // verify a digital signature, if that is required in this security + // environment. It may be required even when using IPSEC security + // infrastructure. + IOP::ServiceContextList service_info; + input >> service_info; + + // This method is going to a copy?? Data copy?? Need to figure out a + // way to avoid this + request.service_info (service_info); + + return hdr_status ? 0 : -1; +} + + +int +TAO_GIOP_Message_Accept_State_12:: + parse_locate_header (TAO_GIOP_Locate_Request_Header &request) +{ + // Get the stream + TAO_InputCDR &msg = request.incoming_stream (); + + CORBA::Boolean hdr_status = 1; + + // Get the request id + CORBA::ULong req_id = 0; + hdr_status = msg.read_ulong (req_id); + + // Store it in the Locate request classes + request.request_id (req_id); + + // + // ADD STUFF + // + // + + + + return hdr_status ? 0 : -1; +} + + + + +CORBA::Boolean +TAO_GIOP_Message_Accept_State_12:: + unmarshall_target_addr (TAO_GIOP_ServerRequest &request, + TAO_InputCDR &input) +{ + CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit (); + + // 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). + + // Read the discriminant of the union. + CORBA::Short disc = 0; + hdr_status = hdr_status && input.read_short (disc); + + if (hdr_status) + { + if (disc == GIOP::KeyAddr) + { + CORBA::Long key_length = 0; + hdr_status = hdr_status && input.read_long (key_length); + if (hdr_status) + { + request.object_key ().replace (key_length, key_length, + (CORBA::Octet*)input.rd_ptr (), + 0); + input.skip_bytes (key_length); + } + } + else if (disc == GIOP::ProfileAddr) + { + // Need to add stuff here, Bala + } + + else if (disc == GIOP::ReferenceAddr) + { + // Need to add stuff here, Bala + } + } + + return hdr_status; +} + + +CORBA::Boolean +TAO_GIOP_Message_Accept_State_12:: +write_reply_header (TAO_OutputCDR & /*output*/, + TAO_Pluggable_Reply_Params & /*reply_params*/, + CORBA::Environment & /*ACE_TRY_ENV*/) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return 1; +} + + +CORBA::Boolean +TAO_GIOP_Message_Accept_State_12:: +write_locate_reply_mesg (TAO_OutputCDR & /*output*/, + CORBA::ULong /*request_id*/, + TAO_GIOP_Locate_Status_Msg & /*status*/) +{ + return 1; +} + + + +CORBA::Octet +TAO_GIOP_Message_Accept_State_12::major_version (void) +{ + return (CORBA::Octet) 1; +} + + +CORBA::Octet +TAO_GIOP_Message_Accept_State_12::minor_version (void) +{ + return (CORBA::Octet) 2; +} + diff --git a/TAO/tao/GIOP_Message_Accept_State.h b/TAO/tao/GIOP_Message_Accept_State.h index fdbfe44ff24..83151f00123 100644 --- a/TAO/tao/GIOP_Message_Accept_State.h +++ b/TAO/tao/GIOP_Message_Accept_State.h @@ -20,6 +20,9 @@ #include "tao/GIOP_Message_Headers.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ // @@ Bala: do we want to have separate classes for the server side // and client side? IMHO not, with bi-directional connections the @@ -45,6 +48,7 @@ class TAO_GIOP_ServerRequest; class TAO_OutputCDR; class TAO_GIOP_Locate_Status_Msg; +class TAO_Pluggable_Reply_Params; class TAO_GIOP_Message_Accept_State { @@ -61,9 +65,13 @@ public: virtual int parse_request_header (TAO_GIOP_ServerRequest &) = 0; // Parse the Request Header from the incoming stream. This will do a // version specific parsing of the incoming Request header - - virtual CORBA::Boolean write_reply_header (TAO_OutputCDR &output, - CORBA::ULong request_id) = 0; + + virtual CORBA::Boolean + write_reply_header (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)) = 0; // Write the reply header in to <output> virtual int parse_locate_header (TAO_GIOP_Locate_Request_Header &) = 0; @@ -80,7 +88,12 @@ public: virtual CORBA::Octet minor_version (void) = 0; // Our versions - private: +protected: + CORBA::Boolean marshal_svc_ctx (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply); + + void marshal_reply_status (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply); }; @@ -114,7 +127,10 @@ public: virtual CORBA::Boolean write_reply_header (TAO_OutputCDR &output, - CORBA::ULong request_id); + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); // Write the version specific reply header in to <output> virtual int parse_locate_header (TAO_GIOP_Locate_Request_Header &); @@ -132,7 +148,9 @@ public: // Our versions }; -/*****************************************************************/ + +/*****************************************************************/ + class TAO_GIOP_Message_Accept_State_11: public TAO_GIOP_Message_Accept_State_10 { // = TITLE @@ -142,6 +160,50 @@ public: virtual CORBA::Octet minor_version (void); }; + + +/********************************************************************/ +class TAO_GIOP_Message_Accept_State_12 : public TAO_GIOP_Message_Accept_State +{ + // = TITLE + // TAO_GIOP_Message_Accept_State_12 + // = DESCRIPTION + // + +public: + virtual int parse_request_header (TAO_GIOP_ServerRequest &); + // Parse the Request Header from the incoming stream. This will do a + // version specific parsing of the incoming Request header + + + virtual CORBA::Boolean + write_reply_header (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply_params, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Write the version specific reply header in to <output> + + virtual int parse_locate_header (TAO_GIOP_Locate_Request_Header &); + // Parse the Loacte Request Header from the incoming stream. This will do a + // version specific parsing of the incoming Request header + + virtual CORBA::Boolean + write_locate_reply_mesg (TAO_OutputCDR &output, + CORBA::ULong request_id, + TAO_GIOP_Locate_Status_Msg &status); + // Writes the locate reply message in to <output> + + virtual CORBA::Octet major_version (void); + virtual CORBA::Octet minor_version (void); + // Our versions + +private: + CORBA::Boolean unmarshall_target_addr (TAO_GIOP_ServerRequest &request, + TAO_InputCDR &input); +}; + + /*****************************************************************/ class TAO_GIOP_Message_Accept_Impl diff --git a/TAO/tao/GIOP_Message_Accept_State.i b/TAO/tao/GIOP_Message_Accept_State.i index 4e4cdc36938..b777583df5c 100644 --- a/TAO/tao/GIOP_Message_Accept_State.i +++ b/TAO/tao/GIOP_Message_Accept_State.i @@ -2,6 +2,10 @@ //$Id$ + + + + /////////////////////////////////////////////////////////////// // TAO_GIOP_Message_Accept_Impl methods ////////////////////////////////////////////////////////////// diff --git a/TAO/tao/GIOP_Message_Acceptors.cpp b/TAO/tao/GIOP_Message_Acceptors.cpp index 5bb82a47604..949cc3ee4d2 100644 --- a/TAO/tao/GIOP_Message_Acceptors.cpp +++ b/TAO/tao/GIOP_Message_Acceptors.cpp @@ -50,6 +50,25 @@ TAO_GIOP_Message_Acceptors:: return 0; } +CORBA::Boolean +TAO_GIOP_Message_Acceptors::write_reply_header (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params ¶ms, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Write the GIOP header first + this->write_protocol_header (TAO_PLUGGABLE_MESSAGE_REPLY, + output); + + // Write the reply header + this->accept_state_->write_reply_header (output, + params, + ACE_TRY_ENV); + + return 0; +} + + int TAO_GIOP_Message_Acceptors:: process_client_request (TAO_Transport *transport, @@ -157,12 +176,17 @@ TAO_GIOP_Message_Acceptors:: #if (TAO_HAS_MINIMUM_CORBA == 0) ACE_CATCH (PortableServer::ForwardRequest, forward_request) { - // Make the GIOP header and Reply header - this->make_reply (request_id, - this->output_); - - this->output_.write_ulong (TAO_GIOP_LOCATION_FORWARD); + TAO_Pluggable_Reply_Params reply_params; + reply_params.request_id_ = request_id; + reply_params.reply_status_ = TAO_GIOP_LOCATION_FORWARD; + reply_params.svc_ctx_.length (0); + reply_params.service_context_notowned (&reply_params.svc_ctx_); + reply_params.params_ = 0; + // Make the GIOP header and Reply header + this->write_reply_header (this->output_, + reply_params); + CORBA::Object_ptr object_ptr = forward_request.forward_reference.in(); @@ -489,9 +513,14 @@ TAO_GIOP_Message_Acceptors:: orb_core->to_iso8859 (), orb_core->to_unicode ()); - // Make the GIOP & reply header. They are version specific. - this->make_reply (request_id, - output); + TAO_Pluggable_Reply_Params reply_params; + reply_params.request_id_ = request_id; + reply_params.svc_ctx_.length (0); + reply_params.service_context_notowned (&reply_params.svc_ctx_); + +#if (TAO_HAS_MINIMUM_CORBA == 0) + reply_params.params_ = 0; +#endif /*TAO_HAS_MINIMUM_CORBA*/ // A new try/catch block, but if something goes wrong now we have no // hope, just abort. @@ -509,9 +538,14 @@ TAO_GIOP_Message_Acceptors:: extype = CORBA::SYSTEM_EXCEPTION; // write the reply_status - output.write_ulong - (TAO_GIOP_Utils::convert_CORBA_to_GIOP_exception (extype)); + reply_params.reply_status_ = + TAO_GIOP_Utils::convert_CORBA_to_GIOP_exception (extype); + + // Make the GIOP & reply header. They are version specific. + this->write_reply_header (output, + reply_params); + // @@ Any way to implement this without interpretive // marshaling??? x->_tao_encode (output, ACE_TRY_ENV); diff --git a/TAO/tao/GIOP_Message_Acceptors.h b/TAO/tao/GIOP_Message_Acceptors.h index 5624a76d017..5a3105cdc23 100644 --- a/TAO/tao/GIOP_Message_Acceptors.h +++ b/TAO/tao/GIOP_Message_Acceptors.h @@ -55,6 +55,17 @@ public: int parse_reply (TAO_Message_State_Factory &mesg_state, TAO_Pluggable_Reply_Params ¶ms); + + + CORBA::Boolean write_reply_header (TAO_OutputCDR &cdr, + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + // This would prepare a version specific reply to the + // messages from the client. The type of reply would be context + // sensitive. Only the common stuff for all the replies to be + // sent would be handled. private: int process_client_request (TAO_Transport *transport, @@ -81,12 +92,6 @@ private: CORBA::Octet major_version (void); CORBA::Octet minor_version (void); - CORBA::Boolean make_reply (CORBA::ULong request_id, - TAO_OutputCDR &output); - // This would prepare a version specific reply to the - // messages from the client. The type of reply would be context - // sensitive. Only the common stuff for all the replies to be - // sent would be handled. int make_send_locate_reply (TAO_Transport *transport, TAO_GIOP_Locate_Request_Header &request, diff --git a/TAO/tao/GIOP_Message_Acceptors.i b/TAO/tao/GIOP_Message_Acceptors.i index 7c07af5c7c2..2d8ad3ec1c9 100644 --- a/TAO/tao/GIOP_Message_Acceptors.i +++ b/TAO/tao/GIOP_Message_Acceptors.i @@ -34,26 +34,6 @@ TAO_GIOP_Message_Acceptors:: } -ACE_INLINE CORBA::Boolean -TAO_GIOP_Message_Acceptors:: - make_reply (CORBA::ULong request_id, - TAO_OutputCDR &output) -{ - // Write the GIOP header first - this->write_protocol_header (TAO_PLUGGABLE_MESSAGE_REPLY, - output); - - // Write the reply header - this->accept_state_->write_reply_header (output, - request_id); - - return 0; - -} - - - - ACE_INLINE void TAO_GIOP_Message_Acceptors:: set_state (CORBA::Octet def_major, diff --git a/TAO/tao/GIOP_Message_Base.cpp b/TAO/tao/GIOP_Message_Base.cpp index 781b936ff69..083b82ddcf4 100644 --- a/TAO/tao/GIOP_Message_Base.cpp +++ b/TAO/tao/GIOP_Message_Base.cpp @@ -222,8 +222,8 @@ TAO_GIOP_Message_Base:: if (retval == -1 && TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO (%P|%t) - %p\n") - ASYS_TEXT ("TAO_GIOP_Message_Base::handle_input"))); + ASYS_TEXT ("TAO (%P|%t) - \n") + ASYS_TEXT ("TAO_GIOP_Message_Base::handle_input \n"))); return -1; } @@ -278,7 +278,7 @@ TAO_GIOP_Message_Base:: if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("TAO (%P|%t) - %p\n"), - ASYS_TEXT ("TAO_GIOP_Message_Base::handle_input, read_buffer[1]"))); + ASYS_TEXT ("TAO_GIOP_Message_Base::handle_input, read_buffer[1] \n"))); return -1; } else if (n == 0) @@ -286,7 +286,7 @@ TAO_GIOP_Message_Base:: if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("TAO (%P|%t) - %p\n"), - ASYS_TEXT ("TAO_GIOP_Message_Base::handle_input, read_buffer[2]"))); + ASYS_TEXT ("TAO_GIOP_Message_Base::handle_input, read_buffer[2]\n"))); return -1; } diff --git a/TAO/tao/GIOP_Message_Base.h b/TAO/tao/GIOP_Message_Base.h index e3a74cf2af9..9f85215b54e 100644 --- a/TAO/tao/GIOP_Message_Base.h +++ b/TAO/tao/GIOP_Message_Base.h @@ -173,6 +173,11 @@ const size_t TAO_GIOP_VERSION_MAJOR_OFFSET = 4; const size_t TAO_GIOP_MESSAGE_FLAGS_OFFSET = 6; const size_t TAO_GIOP_MESSAGE_TYPE_OFFSET = 7; +// This is used by GIOP1.2. This is to align the message body on a +// 8-octet boundary. +const size_t TAO_GIOP_MESSAGE_ALIGN_PTR = 8; + + #if defined (__ACE_INLINE__) # include "tao/GIOP_Message_Base.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/GIOP_Message_Connectors.cpp b/TAO/tao/GIOP_Message_Connectors.cpp index 85891d5b948..fb8efe6d357 100644 --- a/TAO/tao/GIOP_Message_Connectors.cpp +++ b/TAO/tao/GIOP_Message_Connectors.cpp @@ -9,6 +9,7 @@ #include "tao/operation_details.h" #include "tao/GIOP_Utils.h" #include "tao/target_specification.h" +#include "tao/GIOPC.h" #if !defined (__ACE_INLINE__) @@ -126,17 +127,28 @@ TAO_GIOP_Message_Connectors::validate_version (TAO_GIOP_Message_State *state) return 0; } + int -TAO_GIOP_Message_Connectors:: -process_client_message (TAO_Transport * /*transport*/, - TAO_ORB_Core * /*orb_core*/, - TAO_InputCDR & /*input*/, - CORBA::Octet /*message_type*/) +TAO_GIOP_Message_Connectors::process_client_message (TAO_Transport * /*transport*/, + TAO_ORB_Core * /*orb_core*/, + TAO_InputCDR & /*input*/, + CORBA::Octet /*message_type*/) { ACE_NOTSUP_RETURN (-1); } +CORBA::Boolean +TAO_GIOP_Message_Connectors::write_reply_header (TAO_OutputCDR & /*cdr*/, + TAO_Pluggable_Reply_Params & /*params*/, + CORBA::Environment & + /*ACE_TRY_ENV*/) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NOTSUP_RETURN (0); +} + + /////////////////////////////////////////////////////////////////// // Methods for TAO_GIOP_Message_Connector_10 ////////////////////////////////////////////////////////////////// @@ -328,3 +340,199 @@ TAO_GIOP_Message_Connector_11:: minor_version (void) // Any harm in hardcoding?? return (CORBA::Octet) 1; } + +/////////////////////////////////////////////////////////////////// +// Methods for TAO_GIOP_Message_Connector_12 +////////////////////////////////////////////////////////////////// + +CORBA::Boolean +TAO_GIOP_Message_Connector_12:: + write_request_header (const TAO_Operation_Details &opdetails, + TAO_Target_Specification &spec, + TAO_OutputCDR &msg) +{ + // First the request id + msg << opdetails.request_id (); + + const CORBA::Octet response_flags = opdetails.response_flags (); + + // Here are the Octet values for different policies + // '00000000' for SYNC_WITH_TRANSPORT & SYNC_NONE + // '00000001' for SYNC_WITH_SERVER + // '00000011' for SYNC_WITH_TARGET + // '00000011' for regular two ways, but if they are invoked via a + // DII with INV_NO_RESPONSE flag set then we need to send '00000001' + // + // We have not implemented the policy INV_NO_RESPONSE for DII. + if (response_flags == 131) + msg << CORBA::Any::from_octet (3); + // Second the response flags + // Sync scope - ignored by server if request is not oneway. + else if (response_flags == CORBA::Octet (TAO::SYNC_WITH_TRANSPORT) || + response_flags == CORBA::Octet (TAO::SYNC_NONE) || + response_flags == CORBA::Octet (TAO::SYNC_EAGER_BUFFERING) || + response_flags == CORBA::Octet (TAO::SYNC_DELAYED_BUFFERING)) + // No response required. + msg << CORBA::Any::from_octet (0); + + else if (response_flags == CORBA::Octet (TAO::SYNC_WITH_SERVER)) + // Return before dispatching servant. + msg << CORBA::Any::from_octet (1); + + else if (response_flags == CORBA::Octet (TAO::SYNC_WITH_TARGET)) + // Return after dispatching servant. + msg << CORBA::Any::from_octet (3); + + else + // Until more flags are defined by the OMG. + return 0; + + if (this->marshall_target_spec (spec, + msg) == 0) + return 0; + + // Write the operation name + msg.write_string (opdetails.opname_len (), + opdetails.opname ()); + + // Write the service context list + msg << opdetails.service_info (); + + // We need to align the pointer + if (msg.align_write_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR) == -1) + return 0; + + return 1; +} + + +CORBA::Boolean +TAO_GIOP_Message_Connector_12:: + write_locate_request_header (CORBA::ULong request_id, + TAO_Target_Specification &spec, + TAO_OutputCDR &msg) +{ + // Write the request id + msg << request_id; + + // Write the target address + if (this->marshall_target_spec (spec, + msg) == 0) + return 0; + + // We need to align the pointer + if (msg.align_write_ptr (TAO_GIOP_MESSAGE_ALIGN_PTR) == -1) + return 0; + + // Return success + return 1; +} + +CORBA::Octet +TAO_GIOP_Message_Connector_12:: major_version (void) +{ + // Any harm in hardcoding?? + return (CORBA::Octet) 1; +} + +CORBA::Octet +TAO_GIOP_Message_Connector_12:: minor_version (void) +{ + // Any harm in hardcoding?? + return (CORBA::Octet) 2; +} + + +CORBA::Boolean +TAO_GIOP_Message_Connector_12:: + marshall_target_spec (TAO_Target_Specification &spec, + TAO_OutputCDR &msg) +{ + switch (spec.specifier ()) + { + case TAO_Target_Specification::Key_Addr: + { + // As this is a union send in the discriminant first + msg << GIOP::KeyAddr; + + // Get the object key + const TAO_ObjectKey *key = spec.object_key (); + if (key) + { + // Marshall in the object key + msg << *key; + } + else + { + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%N |%l) Unable to handle this request \n"))); + return 0; + } + break; + } + case TAO_Target_Specification::Profile_Addr: + { + // As this is a union send in the discriminant first + msg << GIOP::ProfileAddr; + + // Get the profile + const IOP::TaggedProfile *pfile = spec.profile (); + + if (pfile) + { + // Marshall in the object key + msg << *pfile; + } + else + { + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%N |%l) Unable to handle this request \n"))); + return 0; + } + break; + } + case TAO_Target_Specification::Reference_Addr: + { + // As this is a union send in the discriminant first + msg << GIOP::ReferenceAddr; + + // Get the IOR + IOP::IOR *ior; + CORBA::ULong index = spec.iop_ior (ior); + + if (ior) + { + // This is a struct IORAddressingInfo. So, marshall each + // member of the struct one after another in the order + // defined. + msg << index; + msg << *ior; + } + else + { + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%N |%l) Unable to handle this request \n"))); + return 0; + } + break; + } + default: + if (TAO_debug_level) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%N |%l) Unable to handle this request \n"))); + return 0; + } + + return 1; +} + +int +TAO_GIOP_Message_Connector_12:: +parse_reply (TAO_Message_State_Factory & /*mesg_state*/, + TAO_Pluggable_Reply_Params & /*params*/) +{ + return 0; +} diff --git a/TAO/tao/GIOP_Message_Connectors.h b/TAO/tao/GIOP_Message_Connectors.h index 49d30bf96f0..cd8a2cb40fd 100644 --- a/TAO/tao/GIOP_Message_Connectors.h +++ b/TAO/tao/GIOP_Message_Connectors.h @@ -23,6 +23,12 @@ #include "tao/GIOP_Message_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + // @@ Bala: why are this class called "Connector" does it have // @@ anything to do with establishing connection? It looks more like // @@ request parsing or something like that! @@ -36,6 +42,17 @@ class TAO_Export TAO_GIOP_Message_Connectors: public TAO_GIOP_Message_Base // This class provides methods and code for the connector specific // functionality of GIOP.The motivation for this class is to hold // common code between different versions of GIOP in a single + // class. +public: + + CORBA::Boolean write_reply_header (TAO_OutputCDR &cdr, + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + // This would not be used now. So it will be returning an error + // message. + // @@ This will be implemented once we get to the Bi-Dir GIOP. // class. protected: @@ -84,9 +101,9 @@ public: TAO_GIOP_Message_Connector_10 (void); // Ctor - -protected: - virtual CORBA::Boolean + +private: + virtual CORBA::Boolean write_request_header (const TAO_Operation_Details &opdetails, TAO_Target_Specification &spec, TAO_OutputCDR &msg); @@ -126,6 +143,50 @@ private: // Our minor version }; +/*************************************************************/ +class TAO_Export TAO_GIOP_Message_Connector_12: public TAO_GIOP_Message_Connectors +{ + // = TITLE + // TAO_GIOP_Message_Connector_12 + // = DESCRIPTION + // This class is deribed from the 1.0 version of GIOP. At presnt + // this only returns the right version number + +public: + + TAO_GIOP_Message_Connector_12 (void); + // Ctor + +private: + CORBA::Boolean + write_request_header (const TAO_Operation_Details &opdetails, + TAO_Target_Specification &spec, + TAO_OutputCDR &msg); + // Write the request header in to <msg> + + CORBA::Boolean + write_locate_request_header (CORBA::ULong request_id, + TAO_Target_Specification &spec, + TAO_OutputCDR &msg); + // Write the locate request header in to the <msg> + + int parse_reply (TAO_Message_State_Factory &mesg_state, + TAO_Pluggable_Reply_Params ¶ms); + // Parse the reply messages from the server + + CORBA::Octet major_version (void); + CORBA::Octet minor_version (void); + // Our minor and major versions + + CORBA::Boolean marshall_target_spec (TAO_Target_Specification &spec, + TAO_OutputCDR &msg); + // This is a helper method that would be used by the method, + // write_request_header (). This method extracts the the correct + // specification details from <spec> and marshalls the details in to + // <msg> + +}; + #if defined (__ACE_INLINE__) # include "tao/GIOP_Message_Connectors.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/GIOP_Message_Lite.cpp b/TAO/tao/GIOP_Message_Lite.cpp index 2207a93cea1..6b66ed251e0 100644 --- a/TAO/tao/GIOP_Message_Lite.cpp +++ b/TAO/tao/GIOP_Message_Lite.cpp @@ -7,6 +7,8 @@ #include "tao/POA.h" #include "tao/GIOP_Utils.h" #include "tao/operation_details.h" +#include "tao/GIOP_Server_Request.h" +#include "tao/GIOP_Message_Headers.h" #if !defined (__ACE_INLINE__) # include "tao/GIOP_Message_Lite.i" @@ -135,8 +137,8 @@ TAO_GIOP_Message_Lite:: if (retval == -1 && TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO (%P|%t) - %p\n") - ASYS_TEXT ("TAO_GIOP_Message_Lite::handle_input"))); + ASYS_TEXT ("TAO (%P|%t) - \n") + ASYS_TEXT ("TAO_GIOP_Message_Lite::handle_input \n"))); return -1; } @@ -447,6 +449,151 @@ TAO_GIOP_Message_Lite:: } + + + +CORBA::Boolean +TAO_GIOP_Message_Lite:: + write_reply_header (TAO_OutputCDR &output, + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + + // Write the GIOP Lite header first + this->write_protocol_header (TAO_PLUGGABLE_MESSAGE_REPLY, + output); + + // Write the service context list +#if defined (TAO_HAS_MINIMUM_CORBA) + output << reply.service_context_notowned (); +#else + if (reply.params_ == 0) + { + output << reply.service_context_notowned (); + } + else + { + // If lazy evaluation is enabled then we are going to insert an + // extra node at the end of the service context list, just to + // force the appropiate padding. + // But first we take it out any of them.. + CORBA::ULong count = 0; + IOP::ServiceContextList &svc_ctx = + reply.service_context_notowned (); + CORBA::ULong l = svc_ctx.length (); + CORBA::ULong i; + for (i = 0; i != l; ++i) + { + if (svc_ctx[i].context_id == TAO_SVC_CONTEXT_ALIGN) + continue; + count++; + } + + // Now increment it to account for the last dummy one... + count++; + + // Now marshal the rest of the service context objects + output << count; + for (i = 0; i != l; ++i) + { + if (svc_ctx[i].context_id == TAO_SVC_CONTEXT_ALIGN) + continue; + output << svc_ctx[i]; + } + + // @@ Much of this code is GIOP 1.1 specific and should be + ptr_arith_t target = + reply.params_->_tao_target_alignment (); + + ptr_arith_t current = + ptr_arith_t (output.current_alignment ()) % ACE_CDR::MAX_ALIGNMENT; + + CORBA::ULong pad = 0; + if (target == 0) + { + // We want to generate adequate padding to start the request + // id on a 8 byte boundary, two cases: + // - If the dummy tag starts on a 4 byte boundary and the + // dummy sequence has 0 elements then we have: + // 4:tag 8:sequence_length 4:sequence_body 4:request_id + // 8:payload + // - If the dummy tag starts on an 8 byte boundary, with 4 + // elements we get: + // 8:tag 4:sequence_length 8:sequence_body 4:request_id + // 8:payload + if (current != 0 && current <= ACE_CDR::LONG_ALIGN) + { + pad = 4; + } + } + else if (target != ACE_CDR::LONG_ALIGN) + { + // The situation reverses, we want to generate adequate + // padding to start the request id on a 4 byte boundary, two + // cases: + // - If the dummy tag starts on a 4 byte boundary and the + // dummy sequence has 4 elements then we have: + // 4:tag 8:sequence_length 4:sequence_body 8:request_id + // 4:payload + // - If the dummy tag starts on an 8 byte boundary, with 0 + // elements we get: + // 8:tag 4:sequence_length 8:sequence_body 8:request_id + // 4:payload + if (current > ACE_CDR::LONG_ALIGN) + { + pad = 4; + } + } + else if (target == ACE_CDR::MAX_ALIGNMENT) + { + pad = 0; + } + else + { + // <target> can only have the values above + ACE_THROW_RETURN (CORBA::MARSHAL (), + 0); + } + + output << CORBA::ULong (TAO_SVC_CONTEXT_ALIGN); + output << pad; + for (CORBA::ULong j = 0; j != pad; ++j) + { + output << ACE_OutputCDR::from_octet(0); + } + } +#endif /* TAO_HAS_MINIMUM_CORBA */ + + // Write the request ID + output.write_ulong (reply.request_id_); + + // Write the reply status + switch (reply.reply_status_) + { + case TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION: + output.write_ulong (TAO_GIOP_NO_EXCEPTION); + break; + case TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD: + output.write_ulong (TAO_GIOP_LOCATION_FORWARD); + break; + case TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION: + output.write_ulong (TAO_GIOP_SYSTEM_EXCEPTION); + break; + case TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION: + output.write_ulong (TAO_GIOP_USER_EXCEPTION); + break; + default: + // Some other specifc exception + output.write_ulong (reply.reply_status_); + break; + } + + return 1; +} + + + CORBA::Boolean TAO_GIOP_Message_Lite:: write_request_header (const TAO_Operation_Details &opdetails, @@ -642,15 +789,19 @@ TAO_GIOP_Message_Lite:: #if (TAO_HAS_MINIMUM_CORBA == 0) ACE_CATCH (PortableServer::ForwardRequest, forward_request) { + TAO_Pluggable_Reply_Params reply_params; + reply_params.request_id_ = request_id; + reply_params.reply_status_ = TAO_GIOP_LOCATION_FORWARD; + reply_params.svc_ctx_.length (0); + reply_params.service_context_notowned (&reply_params.svc_ctx_); + reply_params.params_ = 0; // Make the GIOP header and Reply header - this->make_reply (request_id, - this->output_); - - this->output_.write_ulong (TAO_GIOP_LOCATION_FORWARD); + this->write_reply_header (this->output_, + reply_params); CORBA::Object_ptr object_ptr = forward_request.forward_reference.in(); - + this->output_ << object_ptr; // Flag for code below catch blocks. @@ -1087,8 +1238,11 @@ TAO_GIOP_Message_Lite:: orb_core->to_unicode ()); // Make the GIOP & reply header. They are version specific. - this->make_reply (request_id, - output); + TAO_Pluggable_Reply_Params reply_params; + reply_params.request_id_ = request_id; + reply_params.svc_ctx_.length (0); + reply_params.service_context_notowned (&reply_params.svc_ctx_); + reply_params.params_ = 0; // A new try/catch block, but if something goes wrong now we have no // hope, just abort. @@ -1106,8 +1260,13 @@ TAO_GIOP_Message_Lite:: extype = CORBA::SYSTEM_EXCEPTION; // write the reply_status - output.write_ulong - (TAO_GIOP_Utils::convert_CORBA_to_GIOP_exception (extype)); + reply_params.reply_status_ = + TAO_GIOP_Utils::convert_CORBA_to_GIOP_exception (extype); + + // Make the GIOP & reply header. They are version specific. + this->write_reply_header (output, + reply_params); + x->_tao_encode (output, ACE_TRY_ENV); ACE_TRY_CHECK; diff --git a/TAO/tao/GIOP_Message_Lite.h b/TAO/tao/GIOP_Message_Lite.h index 7acb0bc486f..598ee06ea12 100644 --- a/TAO/tao/GIOP_Message_Lite.h +++ b/TAO/tao/GIOP_Message_Lite.h @@ -20,10 +20,20 @@ #define TAO_GIOP_MESSAGE_LITE_H #include "ace/pre.h" -#include "tao/GIOP_Server_Request.h" -#include "tao/GIOP_Message_Headers.h" -#include "tao/target_specification.h" +//#include "tao/target_specification.h" +#include "tao/CDR.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + #include "tao/GIOP_Utils.h" +#include "tao/GIOP_Message_State.h" + +class TAO_GIOP_ServerRequest; +class TAO_GIOP_Locate_Request_Header; + class TAO_Export TAO_GIOP_Message_Lite : public TAO_Pluggable_Messaging { @@ -84,6 +94,13 @@ public: CORBA::Octet message_type); // Processes the messages from the connectors so that they can be // passed on to the appropriate states. + + CORBA::Boolean write_reply_header (TAO_OutputCDR &cdr, + TAO_Pluggable_Reply_Params &reply, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + private: CORBA::Boolean write_request_header (const TAO_Operation_Details &details, @@ -128,9 +145,6 @@ private: int parse_locate_header (TAO_GIOP_Locate_Request_Header &request); // Parse the Locate Request header - CORBA::Boolean make_reply (CORBA::ULong request_id, - TAO_OutputCDR &output); - // Make a reply message including the protocol header int send_reply_exception (TAO_Transport *transport, TAO_ORB_Core* orb_core, diff --git a/TAO/tao/GIOP_Message_Lite.i b/TAO/tao/GIOP_Message_Lite.i index 0815bf79756..c5c25aac236 100644 --- a/TAO/tao/GIOP_Message_Lite.i +++ b/TAO/tao/GIOP_Message_Lite.i @@ -24,27 +24,4 @@ TAO_GIOP_Message_Lite::parse_header (TAO_GIOP_Message_State *state) return 0; } -ACE_INLINE CORBA::Boolean -TAO_GIOP_Message_Lite:: - make_reply (CORBA::ULong request_id, - TAO_OutputCDR &output) -{ - // Write the GIOP header first - // @@ Bala: i still believe it is a bad idea to have those generic - // enums for all the message types.... - this->write_protocol_header (TAO_PLUGGABLE_MESSAGE_REPLY, - output); - - // create and write a dummy context - // We dont really need this. But for some reason the reply is not - // parsable on the receiving side? - // @@ Bala, look in to this - IOP::ServiceContextList resp_ctx; - resp_ctx.length (0); - output << resp_ctx; - - // Write the request ID - output.write_ulong (request_id); - return 0; -} diff --git a/TAO/tao/GIOP_Server_Request.cpp b/TAO/tao/GIOP_Server_Request.cpp index fa01529e33a..2fb6311a7fd 100644 --- a/TAO/tao/GIOP_Server_Request.cpp +++ b/TAO/tao/GIOP_Server_Request.cpp @@ -201,9 +201,7 @@ TAO_GIOP_ServerRequest::set_exception (const CORBA::Any &value, } // Normal exception else - #endif /* TAO_HAS_MINIMUM_CORBA */ - { ACE_NEW_THROW_EX (this->exception_, CORBA::Any (value), @@ -286,117 +284,52 @@ TAO_GIOP_ServerRequest::dsi_marshal (CORBA::Environment &ACE_TRY_ENV) void TAO_GIOP_ServerRequest::init_reply (CORBA::Environment &ACE_TRY_ENV) { - // Construct a REPLY header. - this->mesg_base_->write_protocol_header (TAO_PLUGGABLE_MESSAGE_REPLY, - *this->outgoing_); + // Construct our reply generator + TAO_Pluggable_Reply_Params reply_params; + + // We put all the info that we have in to this <reply_params> and + // call the <write_reply_header> in the + // pluggable_messaging_interface. One point to be noted however is + // that, it was the pluggable_messaging classes who created us and + // delegated us to do work on its behalf. But we would be calling + // back. As we dont have a LOCK or any such things we can call + // pluggable_messaging guys again. We would be on the same thread of + // invocation. So *theoratically* there should not be a problem. + reply_params.request_id_ = this->request_id_; -#if (TAO_HAS_MINIMUM_CORBA == 1) - *this->outgoing_ << this->service_info_; -#else if (this->lazy_evaluation_ == 0 || this->params_ == 0) + reply_params.params_ = 0; + else + reply_params.params_ = this->params_; + + // Pass in the service context + reply_params.service_context_notowned (&this->service_info_); + + // Forward exception only. + if (!CORBA::is_nil (this->forward_location_.in ())) { - *this->outgoing_ << this->service_info_; + reply_params.reply_status_ = TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD; + } + + // Any exception at all. + else if (this->exception_ == 0) + { + reply_params.reply_status_ = TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION; } else { - // If lazy evaluation is enabled then we are going to insert an - // extra node at the end of the service context list, just to - // force the appropiate padding. - // But first we take it out any of them.. - CORBA::ULong count = 0; - CORBA::ULong l = this->service_info_.length (); - CORBA::ULong i; - for (i = 0; i != l; ++i) - { - if (this->service_info_[i].context_id == TAO_SVC_CONTEXT_ALIGN) - continue; - count++; - } - // Now increment it to account for the last dummy one... - count++; - - // Now marshal the rest of the service context objects - *this->outgoing_ << count; - for (i = 0; i != l; ++i) - { - if (this->service_info_[i].context_id == TAO_SVC_CONTEXT_ALIGN) - continue; - *this->outgoing_ << this->service_info_[i]; - } - - // @@ Much of this code is GIOP 1.1 specific and should be - // re-thought once GIOP 1.2 is implemented, this is not a big - // deal because the code is only used in DSI gateways. - ptr_arith_t target = - this->params_->_tao_target_alignment (); - - ptr_arith_t current = - ptr_arith_t(this->outgoing_->current_alignment ()) % ACE_CDR::MAX_ALIGNMENT; - - CORBA::ULong pad = 0; - if (target == 0) - { - // We want to generate adequate padding to start the request - // id on a 8 byte boundary, two cases: - // - If the dummy tag starts on a 4 byte boundary and the - // dummy sequence has 0 elements then we have: - // 4:tag 8:sequence_length 4:sequence_body 4:request_id - // 8:payload - // - If the dummy tag starts on an 8 byte boundary, with 4 - // elements we get: - // 8:tag 4:sequence_length 8:sequence_body 4:request_id - // 8:payload - if (current != 0 && current <= ACE_CDR::LONG_ALIGN) - { - pad = 4; - } - } - else if (target != ACE_CDR::LONG_ALIGN) - { - // The situation reverses, we want to generate adequate - // padding to start the request id on a 4 byte boundary, two - // cases: - // - If the dummy tag starts on a 4 byte boundary and the - // dummy sequence has 4 elements then we have: - // 4:tag 8:sequence_length 4:sequence_body 8:request_id - // 4:payload - // - If the dummy tag starts on an 8 byte boundary, with 0 - // elements we get: - // 8:tag 4:sequence_length 8:sequence_body 8:request_id - // 4:payload - if (current > ACE_CDR::LONG_ALIGN) - { - pad = 4; - } - } - else if (target == ACE_CDR::MAX_ALIGNMENT) - { - pad = 0; - } - else - { - // <target> can only have the values above - ACE_THROW (CORBA::MARSHAL ()); - } - - *this->outgoing_ << CORBA::ULong(TAO_SVC_CONTEXT_ALIGN); - *this->outgoing_ << pad; - for (CORBA::ULong j = 0; j != pad; ++j) - { - *this->outgoing_ << ACE_OutputCDR::from_octet(0); - } + reply_params.reply_status_ = this->exception_type_; } -#endif /* TAO_HAS_MINIMUM_CORBA */ - - this->outgoing_->write_ulong (this->request_id_); - // Standard exceptions are caught in Connect::handle_input + // Construct a REPLY header. + this->mesg_base_->write_reply_header (*this->outgoing_, + reply_params); - // Forward exception only. - if (!CORBA::is_nil (this->forward_location_.in ())) + // Finish the GIOP Reply header, then marshal the exception. + if (reply_params.reply_status_ == + TAO_PLUGGABLE_MESSAGE_LOCATION_FORWARD) { - this->outgoing_->write_ulong (TAO_GIOP_LOCATION_FORWARD); - + // Marshall the forward location pointrr CORBA::Object_ptr object_ptr = this->forward_location_.in (); if ((*this->outgoing_ << object_ptr) == 0) { @@ -406,24 +339,17 @@ TAO_GIOP_ServerRequest::init_reply (CORBA::Environment &ACE_TRY_ENV) return; } } - - // Any exception at all. - else if (this->exception_ == 0) - { - // First finish the GIOP header ... - this->outgoing_->write_ulong (TAO_GIOP_NO_EXCEPTION); - } - else + else if (reply_params.reply_status_ != + TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION) { + // We are checking for NO exception. If there was a NO_EXCEPTION + // type the IDL compiler would marshall the return values, the + // out & inout parameters in to the stream <*this->output> + + // In this special case we only marshall the exception type CORBA::TypeCode_ptr except_tc; - except_tc = this->exception_->type (); - // Finish the GIOP Reply header, then marshal the exception. - // XXX x->type () someday ... - - this->outgoing_->write_ulong (this->exception_type_); - // we use the any's ACE_Message_Block TAO_InputCDR cdr (this->exception_->_tao_get_cdr (), this->exception_->_tao_byte_order ()); @@ -448,21 +374,25 @@ TAO_GIOP_ServerRequest::exception_type (void) void TAO_GIOP_ServerRequest::send_no_exception_reply (TAO_Transport *transport) { - this->mesg_base_->write_protocol_header (TAO_PLUGGABLE_MESSAGE_REPLY, - *this->outgoing_); + // Construct our reply generator + TAO_Pluggable_Reply_Params reply_params; + reply_params.request_id_ = this->request_id_; + reply_params.params_ = 0; + reply_params.svc_ctx_.length (0); - IOP::ServiceContextList resp_ctx; - resp_ctx.length (0); + // Pass in the service context + reply_params.service_context_notowned (& reply_params.svc_ctx_); + + reply_params.reply_status_ = TAO_GIOP_NO_EXCEPTION; - *this->outgoing_ << resp_ctx; - this->outgoing_->write_ulong (this->request_id_); - this->outgoing_->write_ulong (TAO_GIOP_NO_EXCEPTION); + // Construct a REPLY header. + this->mesg_base_->write_reply_header (*this->outgoing_, + reply_params); + // Send the message int result = this->mesg_base_->send_message (transport, *this->outgoing_); - - if (result == -1) { if (TAO_debug_level > 0) diff --git a/TAO/tao/GIOP_Server_Request.h b/TAO/tao/GIOP_Server_Request.h index 495cc63c13c..bf0e97f042f 100644 --- a/TAO/tao/GIOP_Server_Request.h +++ b/TAO/tao/GIOP_Server_Request.h @@ -235,7 +235,7 @@ private: CORBA::ULong request_id_; // Unique identifier for a request - + TAO_ObjectKey object_key_; // The object key of the destination object. diff --git a/TAO/tao/GIOP_Utils.cpp b/TAO/tao/GIOP_Utils.cpp index bf1ec604990..99e86dd8568 100644 --- a/TAO/tao/GIOP_Utils.cpp +++ b/TAO/tao/GIOP_Utils.cpp @@ -79,7 +79,7 @@ TAO_GIOP_Utils::read_buffer (TAO_Transport *transport, } -TAO_GIOP_Reply_Status_Type +TAO_Pluggable_Message_Exception_Type TAO_GIOP_Utils:: convert_CORBA_to_GIOP_exception (CORBA::exception_type corba_type) { @@ -87,16 +87,16 @@ TAO_GIOP_Utils:: switch (corba_type) { case CORBA::NO_EXCEPTION: - return TAO_GIOP_NO_EXCEPTION; + return TAO_PLUGGABLE_MESSAGE_NO_EXCEPTION; case CORBA::SYSTEM_EXCEPTION: - return TAO_GIOP_SYSTEM_EXCEPTION; + return TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION; case CORBA::USER_EXCEPTION: - return TAO_GIOP_USER_EXCEPTION; + return TAO_PLUGGABLE_MESSAGE_USER_EXCEPTION; default: // Don't know what to do here?? - return TAO_GIOP_SYSTEM_EXCEPTION; + return TAO_PLUGGABLE_MESSAGE_SYSTEM_EXCEPTION; } } diff --git a/TAO/tao/GIOP_Utils.h b/TAO/tao/GIOP_Utils.h index 20f8f7cbab5..a75dd09ad99 100644 --- a/TAO/tao/GIOP_Utils.h +++ b/TAO/tao/GIOP_Utils.h @@ -140,7 +140,7 @@ public: size_t len, ACE_Time_Value *max_wait_time = 0); - static TAO_GIOP_Reply_Status_Type + static TAO_Pluggable_Message_Exception_Type convert_CORBA_to_GIOP_exception (CORBA::exception_type corba_type); // Convert the exception type from CORBA to GIOP }; diff --git a/TAO/tao/IIOP_Connect.h b/TAO/tao/IIOP_Connect.h index 8cec46afd1e..a9354341e45 100644 --- a/TAO/tao/IIOP_Connect.h +++ b/TAO/tao/IIOP_Connect.h @@ -38,7 +38,6 @@ - // Forward Decls class TAO_ORB_Core; class TAO_ORB_Core_TSS_Resources; diff --git a/TAO/tao/Pluggable_Messaging.h b/TAO/tao/Pluggable_Messaging.h index 11db7702397..759fc5f77df 100644 --- a/TAO/tao/Pluggable_Messaging.h +++ b/TAO/tao/Pluggable_Messaging.h @@ -23,6 +23,10 @@ #include "tao/Pluggable_Messaging_Utils.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + class TAO_Message_State_Factory; class TAO_Target_Specification; class TAO_Pluggable_Reply_Params; @@ -111,6 +115,17 @@ public: // influenced by GIOP, which has the protocol header, followed by // the message specific header with the message at the end. + virtual CORBA::Boolean + write_reply_header (TAO_OutputCDR &cdr, + TAO_Pluggable_Reply_Params ¶ms, + CORBA::Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)) = 0; + // Write the reply header + // The reply header is a part of any messaging protocol. The + // messaging protocol implementation would implement the way the + // reply header is written. + // @@ Bala: What if the protocol only has message headers and not // 'protocol headers'? // @@ Carlos: The same comment that you gave above. They have to diff --git a/TAO/tao/Pluggable_Messaging_Utils.h b/TAO/tao/Pluggable_Messaging_Utils.h index b99f3e653f0..6cd322ed4d1 100644 --- a/TAO/tao/Pluggable_Messaging_Utils.h +++ b/TAO/tao/Pluggable_Messaging_Utils.h @@ -57,6 +57,24 @@ public: // @@ Carlos: I agree. Please see above. CORBA::ULong reply_status_; // The reply status + + IOP::ServiceContextList &service_context_notowned (void); + void service_context_notowned (IOP::ServiceContextList *svc); + // Get and Set methods for the service context list that we dont + // own. This is useful for cases where the application objects own + // a service context list and would like to pass on their contents + // without a copy. + +#if (TAO_HAS_MINIMUM_CORBA == 0) + CORBA::NVList_ptr params_; + // NV params. + // @@ This is GIOPism. But we need to figure a way to get around + // this. Till then. It would be used only for DSI gateways +#endif /* TAO_HAS_MINIMUM_CORBA */ + +private: + IOP::ServiceContextList *service_context_; + // The service context list that we don't own. }; // @@ Bala: this is a GIOPism too, there is no such thing as locate diff --git a/TAO/tao/Pluggable_Messaging_Utils.i b/TAO/tao/Pluggable_Messaging_Utils.i index d84ab8bfa52..e20035ca557 100644 --- a/TAO/tao/Pluggable_Messaging_Utils.i +++ b/TAO/tao/Pluggable_Messaging_Utils.i @@ -6,7 +6,29 @@ ACE_INLINE TAO_Pluggable_Reply_Params::TAO_Pluggable_Reply_Params (void) :svc_ctx_ (0), request_id_ (0), - reply_status_ (0) + reply_status_ (0), +#if (TAO_HAS_MINIMUM_CORBA == 0) + params_ (0), +#endif /*TAO_HAS_MINIMUM_CORBA*/ + service_context_ (0) + + +{ + +} + + +ACE_INLINE void +TAO_Pluggable_Reply_Params::service_context_notowned (IOP::ServiceContextList *svc) { + this->service_context_ = svc; +} +ACE_INLINE IOP::ServiceContextList & +TAO_Pluggable_Reply_Params::service_context_notowned (void) +{ + return *this->service_context_; } + + + |