diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-10-20 14:25:10 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-10-20 14:25:10 +0000 |
commit | cfc490776d301a2b6fb8c8073da8b5d695c1b39a (patch) | |
tree | 4a17ccf1bf8fae3816ff6911b9688755d0b42ed4 | |
parent | 1561c14f443aa8c4156764e2577ac0c21965507b (diff) | |
download | ATCD-cfc490776d301a2b6fb8c8073da8b5d695c1b39a.tar.gz |
ChangeLogTag:Wed Oct 20 09:21:27 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
-rw-r--r-- | TAO/ChangeLog-99c | 19 | ||||
-rw-r--r-- | TAO/tao/GIOP_Server_Request.cpp | 91 | ||||
-rw-r--r-- | TAO/tao/NVList.cpp | 35 | ||||
-rw-r--r-- | TAO/tao/NVList.h | 7 | ||||
-rw-r--r-- | TAO/tao/corbafwd.h | 8 | ||||
-rw-r--r-- | TAO/tests/DSI_Gateway/gateway.cpp | 39 | ||||
-rw-r--r-- | TAO/tests/DSI_Gateway/test_dsi.cpp | 123 | ||||
-rw-r--r-- | TAO/tests/DSI_Gateway/test_dsi.h | 10 |
8 files changed, 159 insertions, 173 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c index 2094f891309..0892dc99c4b 100644 --- a/TAO/ChangeLog-99c +++ b/TAO/ChangeLog-99c @@ -1,3 +1,22 @@ +Wed Oct 20 09:21:27 1999 Carlos O'Ryan <coryan@cs.wustl.edu> + + * tao/corbafwd.h: + * tao/NVList.h: + * tao/NVList.cpp: + * tao/GIOP_Server_Request.cpp: + Using a ServiceContext we can insert padding to ensure that the + payload of the message is preserved in DSI gateways. This let us + further reduce the number of data copies and memory + allocations. + + * tests/DSI_Gateway/test_dsi.h: + * tests/DSI_Gateway/test_dsi.cpp: + Use the new features to implement DSI forwarding of requests + without *any* marshaling/demarshaling. + + * tests/DSI_Gateway/gateway.cpp: + Removed debugging code. + Wed Oct 20 08:45:00 1999 Michael Kircher <Michael.Kircher@mchp.siemens.de> * TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp: diff --git a/TAO/tao/GIOP_Server_Request.cpp b/TAO/tao/GIOP_Server_Request.cpp index acea336087b..1e3d8a34690 100644 --- a/TAO/tao/GIOP_Server_Request.cpp +++ b/TAO/tao/GIOP_Server_Request.cpp @@ -552,7 +552,96 @@ TAO_GIOP_ServerRequest::init_reply (CORBA::Environment &ACE_TRY_ENV) *this->outgoing_, this->orb_core_); - *this->outgoing_ << this->service_info_; + if (this->lazy_evaluation_ == 0 || this->params_ == 0) + { + *this->outgoing_ << this->service_info_; + } + 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 (); + + // <target> can only have two values: either it is 0 o + // ACE_CDR::LONG_ALIGN, because the request payload always + // follows the request id. + if (target != 0 && target != ACE_CDR::LONG_ALIGN) + ACE_THROW (CORBA::MARSHAL ()); + + ptr_arith_t current = + ptr_arith_t(this->outgoing_->current ()->wr_ptr ()) + % 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 + { + // 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; + } + } + *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); + } + } this->outgoing_->write_ulong (this->request_id_); // Standard exceptions are caught in Connect::handle_input diff --git a/TAO/tao/NVList.cpp b/TAO/tao/NVList.cpp index 233d06c67e6..cd500a4a245 100644 --- a/TAO/tao/NVList.cpp +++ b/TAO/tao/NVList.cpp @@ -275,10 +275,18 @@ CORBA_NVList::item (CORBA::ULong n, CORBA::Environment &ACE_TRY_ENV) void CORBA_NVList::_tao_incoming_cdr (TAO_InputCDR &cdr, int flag, - int lazy_evaluation, + int &lazy_evaluation, CORBA::Environment &ACE_TRY_ENV) { - if (!lazy_evaluation) + // If the list is empty then using lazy evaluation is the only + // choice. + // @@ There are other cases where we can use lazy evaluation, for + // example if the list is not empty but the anys own all their + // objects. + if (lazy_evaluation == 0 && this->max_ == 0) + lazy_evaluation = 1; + + if (lazy_evaluation == 0) { this->_tao_decode (cdr, flag, @@ -305,6 +313,17 @@ CORBA_NVList::_tao_encode (TAO_OutputCDR &cdr, ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_); if (this->incoming_ != 0) { + if (this->max_ == 0) + { + // The list is empty aggresively reduce copies and just send + // the CDR stream, we assume that + // GIOP_Server_Request::init_reply + // has inserted appropiated padding already to make this + // operation correct + cdr.write_octet_array_mb (this->incoming_->start ()); + return; + } + // Then unmarshal each "in" and "inout" parameter. ACE_Unbounded_Queue_Iterator<CORBA::NamedValue_ptr> i (this->values_); @@ -400,6 +419,18 @@ CORBA_NVList::_tao_decode (TAO_InputCDR &incoming, } } +ptr_arith_t +CORBA_NVList::_tao_target_alignment (void) +{ + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->refcount_lock_, + ACE_CDR::MAX_ALIGNMENT); + if (this->incoming_ == 0) + return ACE_CDR::MAX_ALIGNMENT; + + const char* rd = this->incoming_->start ()->rd_ptr (); + return ptr_arith_t(rd) % ACE_CDR::MAX_ALIGNMENT; +} + void CORBA_NVList::evaluate (CORBA::Environment &ACE_TRY_ENV) { diff --git a/TAO/tao/NVList.h b/TAO/tao/NVList.h index 57b8dc0429f..c8b353ed14b 100644 --- a/TAO/tao/NVList.h +++ b/TAO/tao/NVList.h @@ -242,7 +242,7 @@ public: void _tao_incoming_cdr (TAO_InputCDR &cdr, int flag, - int lazy_evaluation, + int &lazy_evaluation, CORBA::Environment &ACE_TRY_ENV); // Set the incoming CDR stream, this is used by TAO to perform lazy // evaluation of the NVList in an incoming ServerRequest. @@ -262,6 +262,11 @@ public: CORBA::Environment &ACE_TRY_ENV); // Decode the NVList arguments from the <cdr> stream. + ptr_arith_t _tao_target_alignment (void); + // Return the required alignment to marshal the NVList without any + // re-alignment. + // It returns ACE_CDR::MAX_ALIGNMENT to indicate errors. + // Useful for template programming. #if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8 typedef CORBA_NVList_ptr _ptr_type; diff --git a/TAO/tao/corbafwd.h b/TAO/tao/corbafwd.h index 6528c3de6ce..555d81d772e 100644 --- a/TAO/tao/corbafwd.h +++ b/TAO/tao/corbafwd.h @@ -1722,7 +1722,13 @@ TAO_NAMESPACE_CLOSE // end of class (namespace) CORBA // We reserved the range 0x54414f00 - 0x54414f0f with the OMG to // define our own service context list entries. -// #define TAO_SOME_SVC_CONTEXT_ENTRY 0x54414f00U + +// We insert a dummy service context in the service context list to +// preserve the alignment in DSI based gateways, so no +// marshaling/demarshaling is required. This is *extremely* brittle, +// but works. +#define TAO_SVC_CONTEXT_ALIGN 0x54414f00U + // This number was assigned by the OMG. Do *NOT* change at random. // The ASCII representation is TA0xxxx, close enough since they only diff --git a/TAO/tests/DSI_Gateway/gateway.cpp b/TAO/tests/DSI_Gateway/gateway.cpp index 7135ec99c62..50a7de67364 100644 --- a/TAO/tests/DSI_Gateway/gateway.cpp +++ b/TAO/tests/DSI_Gateway/gateway.cpp @@ -79,39 +79,6 @@ main (int argc, char *argv[]) poa_manager->activate (ACE_TRY_ENV); ACE_TRY_CHECK; -#if 0 - CORBA::PolicyList policies (3); - policies.length (3); - - policies[0] = - root_poa->create_id_assignment_policy (PortableServer::USER_ID, - ACE_TRY_ENV); - ACE_TRY_CHECK; - policies[1] = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT, - ACE_TRY_ENV); - policies[2] = - root_poa->create_servant_retention_policy (PortableServer::RETAIN, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - PortableServer::POA_var child_poa = - root_poa->create_POA ("ChildPOA", - poa_manager.in (), - policies, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - for (CORBA::ULong i = 0; - i < policies.length (); - ++i) - { - CORBA::Policy_ptr policy = policies[i]; - policy->destroy (ACE_TRY_ENV); - ACE_TRY_CHECK; - } -#endif /* 0 */ - if (parse_args (argc, argv) != 0) return 1; @@ -134,7 +101,6 @@ main (int argc, char *argv[]) DSI_Simple_Server server_impl (orb.in (), target.in (), root_poa.in ()); -#if 1 PortableServer::ObjectId_var oid = root_poa->activate_object (&server_impl, ACE_TRY_ENV); @@ -144,11 +110,6 @@ main (int argc, char *argv[]) root_poa->id_to_reference (oid.in (), ACE_TRY_ENV); ACE_TRY_CHECK; -#else - CORBA::Object_var server = - server_impl._this (ACE_TRY_ENV); - ACE_TRY_CHECK; -#endif CORBA::String_var ior = orb->object_to_string (server.in (), ACE_TRY_ENV); diff --git a/TAO/tests/DSI_Gateway/test_dsi.cpp b/TAO/tests/DSI_Gateway/test_dsi.cpp index 5ed2528837c..ca2968cc901 100644 --- a/TAO/tests/DSI_Gateway/test_dsi.cpp +++ b/TAO/tests/DSI_Gateway/test_dsi.cpp @@ -14,109 +14,24 @@ DSI_Simple_Server::invoke (CORBA::ServerRequest_ptr request, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { - if (ACE_OS::strcmp ("_is_a", request->operation ()) == 0) + if (ACE_OS::strcmp ("shutdown", request->operation ()) == 0) { - this->is_a_impl (request, ACE_TRY_ENV); + this->orb_->shutdown (0, ACE_TRY_ENV); } - else if (ACE_OS::strcmp ("shutdown", request->operation ()) == 0) - { - this->shutdown_impl (request, ACE_TRY_ENV); - } - else if (ACE_OS::strcmp ("test_method", request->operation ()) == 0) - { - this->test_method_impl (request, ACE_TRY_ENV); - } - else - { - CORBA::Any any; - CORBA::BAD_OPERATION bad_op; - any <<= bad_op; - request->set_exception (any, ACE_TRY_ENV); - } -} - -void -DSI_Simple_Server::is_a_impl (CORBA::ServerRequest_ptr request, - CORBA::Environment &ACE_TRY_ENV) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - CORBA::NVList_ptr list; - this->orb_->create_list (0, list, ACE_TRY_ENV); - ACE_CHECK; - - CORBA::Any any_id (CORBA::_tc_string); - - list->add_value ("id", any_id, CORBA::ARG_IN); - - request->arguments (list, ACE_TRY_ENV); - ACE_CHECK; - - CORBA::Any_ptr id_ptr = - list->item (0, ACE_TRY_ENV)->value (); - ACE_CHECK; - - char* id; - (*id_ptr) >>= id; - - ACE_DEBUG ((LM_DEBUG, "DSI_Simple_Server::is_a - <%s>\n", - id)); - CORBA::Boolean result = 0; - if (ACE_OS::strcmp ("IDL:Simple_Server:1.0", id) == 0 - || ACE_OS::strcmp ("IDL:omg.org/CORBA/Object:1.0", id) == 0) - result = 1; - - CORBA::Any any_result; - any_result <<= CORBA::Any::from_boolean (result); - request->set_result (any_result, ACE_TRY_ENV); -} - -void -DSI_Simple_Server::shutdown_impl (CORBA::ServerRequest_ptr, - CORBA::Environment &ACE_TRY_ENV) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - this->target_->shutdown (ACE_TRY_ENV); - ACE_CHECK; - - this->orb_->shutdown (0, ACE_TRY_ENV); -} - -void -DSI_Simple_Server::test_method_impl (CORBA::ServerRequest_ptr request, - CORBA::Environment &ACE_TRY_ENV) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ CORBA::NVList_ptr list; this->orb_->create_list (0, list, ACE_TRY_ENV); ACE_CHECK; - CORBA::Any x (CORBA::_tc_long); - CORBA::Any the_in_structure (_tc_Structure); - CORBA::Any the_out_structure (_tc_Structure); - CORBA::Any name (CORBA::_tc_string); - - list->add_value ("x" , x , CORBA::ARG_IN ); - list->add_value ("the_in_structure" , the_in_structure , CORBA::ARG_IN ); - list->add_value ("the_out_structure", the_out_structure, CORBA::ARG_OUT ); - list->add_value ("name" , name , CORBA::ARG_INOUT); - - request->_tao_lazy_evaluation (1); request->arguments (list, ACE_TRY_ENV); ACE_CHECK; - CORBA::NamedValue_var nv; - this->orb_->create_named_value (nv.out (), ACE_TRY_ENV); - ACE_CHECK; - - *nv->value () = CORBA::Any (CORBA::_tc_long); - CORBA::Request_var target_request; this->target_->_create_request (0, // ctx - "test_method", + request->operation (), list, - nv.in (), + 0, // result 0, // exception_list, 0, // context_list, target_request.inout (), @@ -128,36 +43,6 @@ DSI_Simple_Server::test_method_impl (CORBA::ServerRequest_ptr request, target_request->invoke (ACE_TRY_ENV); ACE_CHECK; - - request->set_result (target_request->return_value (), - ACE_TRY_ENV); - ACE_CHECK; - - if (TAO_debug_level > 4) - { - CORBA::Long arg_x; - Structure* arg_the_out_structure; - char* arg_name; - - target_request->return_value () >>= arg_x; - CORBA::NamedValue_ptr nv0 = list->item (2, ACE_TRY_ENV); - ACE_CHECK; - CORBA::NamedValue_ptr nv1 = list->item (3, ACE_TRY_ENV); - ACE_CHECK; - *(nv0->value ()) >>= arg_the_out_structure; - *(nv1->value ()) >>= arg_name; - - ACE_DEBUG ((LM_DEBUG, - "DSI_Simpler_Server ====\n" - " x = %d\n" - " i = %d\n" - " length = %d\n" - " name = <%s>\n", - arg_x, - arg_the_out_structure->i, - arg_the_out_structure->seq.length (), - arg_name)); - } } CORBA::RepositoryId diff --git a/TAO/tests/DSI_Gateway/test_dsi.h b/TAO/tests/DSI_Gateway/test_dsi.h index 1dc4ad42bb7..db53b03fcde 100644 --- a/TAO/tests/DSI_Gateway/test_dsi.h +++ b/TAO/tests/DSI_Gateway/test_dsi.h @@ -32,16 +32,6 @@ public: PortableServer::POA_ptr poa); // ctor - void is_a_impl (CORBA::ServerRequest_ptr request, - CORBA::Environment &env) - ACE_THROW_SPEC ((CORBA::SystemException)); - void shutdown_impl (CORBA::ServerRequest_ptr request, - CORBA::Environment &env) - ACE_THROW_SPEC ((CORBA::SystemException)); - void test_method_impl (CORBA::ServerRequest_ptr request, - CORBA::Environment &env) - ACE_THROW_SPEC ((CORBA::SystemException)); - // = The DynamicImplementation methods. virtual void invoke (CORBA::ServerRequest_ptr request, CORBA::Environment &env) |