diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-08-19 19:36:51 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-08-19 19:36:51 +0000 |
commit | a49e2c040c0d88808796d5ca7ed9390f0e2e55c0 (patch) | |
tree | b12af382dcca8ded781a405ef25e9b6958d95a95 | |
parent | 3272dbfd06fa408c0c6812b2b64c569cf2fc6359 (diff) | |
download | ATCD-a49e2c040c0d88808796d5ca7ed9390f0e2e55c0.tar.gz |
ChangeLogTag:Sat Aug 19 11:10:40 2000 Carlos O'Ryan <coryan@uci.edu>
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 109 | ||||
-rw-r--r-- | TAO/tao/POA.cpp | 14 | ||||
-rw-r--r-- | TAO/tao/Policy_Factory.h | 11 | ||||
-rw-r--r-- | TAO/tao/Policy_Factory.i | 6 | ||||
-rw-r--r-- | TAO/tao/Profile.cpp | 64 | ||||
-rw-r--r-- | TAO/tao/RT_Policy_i.cpp | 5 | ||||
-rw-r--r-- | TAO/tao/RT_Policy_i.h | 13 | ||||
-rw-r--r-- | TAO/tao/Stub.cpp | 47 | ||||
-rw-r--r-- | TAO/tests/Exposed_Policies/Counter.idl | 2 | ||||
-rw-r--r-- | TAO/tests/Exposed_Policies/Counter_i.cpp | 2 | ||||
-rw-r--r-- | TAO/tests/Exposed_Policies/Counter_i.h | 2 | ||||
-rw-r--r-- | TAO/tests/Exposed_Policies/RT_Properties.cpp | 31 | ||||
-rw-r--r-- | TAO/tests/Exposed_Policies/client.cpp | 116 | ||||
-rw-r--r-- | TAO/tests/Exposed_Policies/server.cpp | 91 |
14 files changed, 362 insertions, 151 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 03d2e9a3094..38f87dfd250 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,20 @@ +Sat Aug 19 11:10:40 2000 Carlos O'Ryan <coryan@uci.edu> + + * tao/POA.cpp: + * tao/Policy_Factory.h: + * tao/Policy_Factory.i: + * tao/Profile.cpp: + * tao/RT_Policy_i.cpp: + * tao/RT_Policy_i.h: + * tao/Stub.cpp: + * tests/Exposed_Policies/Counter.idl: + * tests/Exposed_Policies/Counter_i.cpp: + * tests/Exposed_Policies/Counter_i.h: + * tests/Exposed_Policies/RT_Properties.cpp: + * tests/Exposed_Policies/client.cpp: + * tests/Exposed_Policies/server.cpp: + Made a code review for Angelo, lots of @@ comments to address. + Sat Aug 19 13:50:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> * TAO_IDL/be/be_visitor_operation/interceptors_ch.cpp: @@ -35,8 +52,10 @@ Fri Aug 18 23:20:56 2000 Marina Spivak <marina@cs.wustl.edu> ptc/99-05-03). Fri Aug 18 19:30:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> + Visitors implemented as part of the TAO_IDL to generate infrastructure for Portable Interceptors: + * TAO_IDL/be_include/be_visitor_argument/paramlist.h * TAO_IDL/be_include/be_visitor_argument/request_info_arglist.h: * TAO_IDL/be_include/be_visitor_interface.h @@ -65,25 +84,31 @@ Fri Aug 18 19:30:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> * TAO_IDL/be/be_visitor_operation/interceptors_sh.cpp: * TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp: * TAO_IDL/be/be_visitor_operation/interceptors_info_rettype.cpp - A new visitor need to attach ACE_NESTED_CLASS macros needed for MSCV. + A new visitor need to attach ACE_NESTED_CLASS macros needed for + MSCV. + * TAO_IDL/be/be_visitor_argument.cpp: * TAO_IDL/be/be_visitor_argument/request_info_ch.cpp: - This one has special MSVC related nested class macro generation - for sequences, structs, arrays & unions. + This one has special MSVC related nested class macro generation + for sequences, structs, arrays & unions. + * TAO_IDL/be/be_visitor_argument/request_info_cs.cpp: * TAO_IDL/be/be_visitor_argument/request_info_result.cpp: * TAO_IDL/be/be_visitor_argument/request_info_sh.cpp: * TAO_IDL/be/be_visitor_argument/request_info_ss.cpp: * TAO_IDL/be/be_visitor_argument/paramlist.cpp: * TAO_IDL/be/be_visitor_argument/request_info_arglist.cpp: - MSVC related changes for the constructor's formal args - for the request info classes. + MSVC related changes for the constructor's formal args for the + request info classes. + * TAO_IDL/be/be_visitor_attribute/attribute.cpp: - Most of the TAO_IDL changes are to add new visitors for generation - of the nested RequestInfo classes per operation of an interface - and also to be able to query the RequestInfo classes for argument - list etc on demand. + Most of the TAO_IDL changes are to add new visitors for + generation of the nested RequestInfo classes per operation of an + interface and also to be able to query the RequestInfo classes + for argument list etc on demand. + TAO/tao additions: + * tao/PortableInterceptor.{h,i,cpp}: * tao/PortableInterceptorC.{h,i,cpp}: * tao/DynamicC.{h,i,cpp}: @@ -91,36 +116,47 @@ Fri Aug 18 19:30:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> * tao/Dynamic.pidl: * tao/IOP_N.pidl: * tao/Request_Info.{h,cpp}: - All the above are new Portable Interceptor related additions - to TAO/tao. + All the above are new Portable Interceptor related additions + to TAO/tao. + * tao/ORB.h: * tao/corba.h: - included PortableInterceptor.h + included PortableInterceptor.h + * tao/ImplRepoC,S.cpp: - commented out inclusion of PortbaleInterceptor.h - And removed all interceptor invocation portions. + commented out inclusion of PortbaleInterceptor.h + And removed all interceptor invocation portions. + * tao/InterfaceC.cpp: - commented out inclusion of PortbaleInterceptor.h - And removed all interceptor invocation portions. + commented out inclusion of PortbaleInterceptor.h + And removed all interceptor invocation portions. + * tao/FT_CORBAC.cpp: - commented out inclusion of PortbaleInterceptor.h - And removed all interceptor invocation portions. + commented out inclusion of PortbaleInterceptor.h + And removed all interceptor invocation portions. + * tao/FT_CORBAS.cpp: - removed all interceptor invocation portions. + removed all interceptor invocation portions. + * tao/Policy{C,S}.cpp: - Removed interceptor points from invocations. + Removed interceptor points from invocations. + * TAO/tao/Makefile: updated dependencies. * TAO/tao/TAO.dsp: * TAO/tao/TAO_Static.dsp: - Updated the NT projects. + Updated the NT projects. + Removed the old interceptor files: + * TAO/tao/Interceptor.{h, i, cpp}: * TAO/tao/InterceptorC.{h, i, cpp}: * TAO/tao/Interceptor.pidl * TAO/tests/Interceptors - All the above are no longer available! + All the above are no longer available! + The following are tests to check out how well this feature performs when providing a different functionality: + * tests/PortableInterceptors/Dynamic/Makefile: * tests/PortableInterceptors/Dynamic/Makefile.bor: * tests/PortableInterceptors/Dynamic/README: @@ -134,8 +170,9 @@ Fri Aug 18 19:30:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> * tests/PortableInterceptors/Dynamic/test.idl: * tests/PortableInterceptors/Dynamic/test_i.cpp: * tests/PortableInterceptors/Dynamic/test_i.h: - This test tries out the various features provided by Module - Dynamic. + This test tries out the various features provided by Module + Dynamic. + * tests/PortableInterceptors/Service_Context_Manipulation/Makefile: * tests/PortableInterceptors/Service_Context_Manipulation/Makefile.bor: * tests/PortableInterceptors/Service_Context_Manipulation/README: @@ -149,8 +186,9 @@ Fri Aug 18 19:30:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> * tests/PortableInterceptors/Service_Context_Manipulation/test.idl: * tests/PortableInterceptors/Service_Context_Manipulation/test_i.cpp: * tests/PortableInterceptors/Service_Context_Manipulation/test_i.h: - This test plays with piggybacking data via the service context - list of the invocation. + This test plays with piggybacking data via the service context + list of the invocation. + * tests/PortableInterceptors/Benchmark/Makefile: * tests/PortableInterceptors/Benchmark/Makefile.bor: * tests/PortableInterceptors/Benchmark/README: @@ -166,13 +204,14 @@ Fri Aug 18 19:30:00 2000 Kirthika Parameswaran <kirthika@cs.wustl.edu> * tests/PortableInterceptors/Benchmark/test_i.h: * tests/PortableInterceptors/Benchmark/marker.h: * tests/PortableInterceptors/Benchmark/marker.cpp: - This is a benchamrking test used and explained in - http://www.cs.wustl.edu/~schmidt/PDF/COOTS-00.pdf - * TAO/docs/interceptor.html: updated documentation to - reflect these changes. - Thanks to Nanbor for brainstorming and guidance, - Jeff for help on nitty-gritty IDL bugs and Doug on helping - to put all this on white paper! + This is a benchamrking test used and explained in + http://www.cs.wustl.edu/~schmidt/PDF/COOTS-00.pdf + + * TAO/docs/interceptor.html: + updated documentation to reflect these changes. + Thanks to Nanbor for brainstorming and guidance, + Jeff for help on nitty-gritty IDL bugs and Doug on helping to + put all this on white paper! Fri Aug 18 17:46:34 2000 Balachandran Natarajan <bala@cs.wustl.edu> @@ -469,8 +508,8 @@ Mon Aug 14 10:23:01 2000 Angelo Corsaro <corsaro@cs.wustl.edu> * tao/POA.cpp (client_exposed_policies): Changed <client_exposed_policies> constructor, and - setted the length of the policy list, (before it was - set just the max size in the constructor but not the + set the length of the policy list, (before it was + just the max size in the constructor was initialized but not the size of the list). * tao/POA.cpp (client_exposed_policies): diff --git a/TAO/tao/POA.cpp b/TAO/tao/POA.cpp index 4d59488909f..8d89a00c06e 100644 --- a/TAO/tao/POA.cpp +++ b/TAO/tao/POA.cpp @@ -37,6 +37,10 @@ #pragma warning(disable:4250) #endif /* _MSC_VER */ +// @@ Darrell: could you move this to some other file? It is kind of +// ugly around here. Also: we probably want this "optional", +// i.e. some kind of hook that creates this object only when IMR is +// enabled, we should talk about it. class ServerObject_i : public POA_ImplementationRepository::ServerObject, public PortableServer::RefCountServantBase @@ -56,10 +60,10 @@ public: { } - virtual void shutdown (CORBA::Environment &) + virtual void shutdown (CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC (()) { - this->orb_->shutdown (); + this->orb_->shutdown (0, ACE_TRY_ENV); } private: CORBA::ORB_ptr orb_; @@ -531,7 +535,7 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, if (this->server_object_) { TAO_POA *root_poa = this->orb_core ().root_poa (); - + PortableServer::ObjectId_var id = root_poa->servant_to_id_i (this->server_object_, ACE_TRY_ENV); ACE_CHECK; @@ -3956,7 +3960,7 @@ TAO_POA::client_exposed_policies (CORBA::Short object_priority, CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_NO)); ACE_CHECK_RETURN (0); - + client_exposed_policies->length (client_exposed_fixed_policies.length ()); for (CORBA::ULong i = 0; @@ -4031,7 +4035,7 @@ TAO_POA::imr_notify_startup (CORBA_Environment &ACE_TRY_ENV) // Activate the servant in the root poa. TAO_POA *root_poa = this->orb_core ().root_poa (); - PortableServer::ObjectId_var id = + PortableServer::ObjectId_var id = root_poa->activate_object_i (this->server_object_, TAO_INVALID_PRIORITY, ACE_TRY_ENV); diff --git a/TAO/tao/Policy_Factory.h b/TAO/tao/Policy_Factory.h index d06c6fc3a2b..bd90c8f1ce8 100644 --- a/TAO/tao/Policy_Factory.h +++ b/TAO/tao/Policy_Factory.h @@ -36,6 +36,17 @@ class TAO_Export TAO_Policy_Factory public: + // @@ Angelo: I don't think this is a good design, in the future we + // may want to have the ORB create the policies, and maybe pluggin + // new policies on the fly (such as protocol specific policies, + // security policies, etc. etc.). + // IMnsHO the right way to do this is to have it implemented in + // the ORB, right now I guess we will have to hard code it, but + // eventually we want to dynamically load the policies, much like + // we can dynamically load protocols. The ORB would use the + // <ptype> to find the right protocol factory from a dynamically + // constructed list. + // static CORBA::Policy * create_policy (CORBA::PolicyType ptype); // Creates a Policy of the type specified by <ptype>. NULL is // returned if the policy type is unknown. diff --git a/TAO/tao/Policy_Factory.i b/TAO/tao/Policy_Factory.i index 8562f0e0bd2..dcb8d6df032 100644 --- a/TAO/tao/Policy_Factory.i +++ b/TAO/tao/Policy_Factory.i @@ -2,11 +2,15 @@ #if (TAO_HAS_RT_CORBA == 1) +// @@ Angelo: we rarely include files in the .i file, and generally +// try to avoid that. # include "tao/RT_Policy_i.h" # include "tao/RTCORBAC.h" #endif /* (TAO_HAS_RT_CORBA == 1) */ +// @@ Angelo: it looks like this function is going to grow over time, +// should go into the .cpp file. ACE_INLINE CORBA::Policy * TAO_Policy_Factory::create_policy (CORBA::PolicyType ptype) { @@ -24,7 +28,7 @@ TAO_Policy_Factory::create_policy (CORBA::PolicyType ptype) ACE_NEW_RETURN (policy, TAO_ClientProtocolPolicy, 0); #else - ACE_UNUSED_ARG (ptype); + ACE_UNUSED_ARG (ptype); #endif /* (TAO_HAS_RT_CORBA == 1) */ diff --git a/TAO/tao/Profile.cpp b/TAO/tao/Profile.cpp index 48185089348..480ddfc6911 100644 --- a/TAO/tao/Profile.cpp +++ b/TAO/tao/Profile.cpp @@ -23,7 +23,12 @@ void TAO_Profile::policies (CORBA::PolicyList *policy_list) { #if (TAO_HAS_CORBA_MESSAGING == 1) - + + // @@ Angelo: using assert will crash the program, that is *NOT* the + // behavior we want, not in a production system. We should log the + // error (if we had systematic logging in TAO, otherwise an + // ACE_DEBUG will have to do), and continue executing! + ACE_ASSERT (policy_list != 0); Messaging::PolicyValue pv; @@ -43,7 +48,7 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); (*policy_list)[i]->_tao_encode (out_CDR); - + length = out_CDR.total_length (); policy_value_seq[i].pvalue.length (length); @@ -60,13 +65,15 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) } //policy_value_seq[i] = pv; - + // Reset the CDR buffer index so that the buffer can // be reused for the next conversion. //out_CDR.reset (); } - + + // @@ Angelo: may want to give this variable another name, to avoid + // confusion. TAO_OutputCDR out_CDR; // Now we have to embedd the Messaging::PolicyValueSeq into // a TaggedComponent. @@ -76,12 +83,12 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER); out_CDR << policy_value_seq; - + length = out_CDR.total_length (); - tagged_component.component_data.length(length); + tagged_component.component_data.length (length); buf = tagged_component.component_data.get_buffer (); - + int i_length; for (const ACE_Message_Block *iterator = out_CDR.begin (); iterator != 0; @@ -92,13 +99,14 @@ TAO_Profile::policies (CORBA::PolicyList *policy_list) ACE_OS::memcpy (buf, iterator->rd_ptr (), iterator->length ()); buf += iterator->length (); - + i_length = iterator->length (); } // Eventually we add the TaggedComponent to the TAO_TaggedComponents // member variable. tagged_components_.set_component (tagged_component); + // @@ Angelo: never forget your this-> are_policies_parsed_ = 1; #else /* TAO_HAS_CORBA_MESSAGING == 1 */ @@ -113,8 +121,16 @@ CORBA::PolicyList& TAO_Profile::policies (void) { #if (TAO_HAS_CORBA_MESSAGING == 1) - + CORBA::PolicyList *policies = this->stub_->base_profiles ().policy_list (); + + // @@ Angelo: the following code does not seem to be thread safe. + // Two threads could call this routine simulatenously and you + // would leak memory like a hog. + // If there are good reasons why that cannot happen please + // document them, if not then please make the code thread safe, a + // regular guard will do. + if (!are_policies_parsed_ && (policies->length () == 0)) // None has already parsed the policies. @@ -154,15 +170,17 @@ TAO_Profile::policies (void) for (CORBA::ULong i = 0; i < length; i++) { + // @@ Angelo: please check my comments on this stuff in + // the Policy_Factory.h file. policy = TAO_Policy_Factory::create_policy (policy_value_seq[i].ptype); if (policy != 0) { buf = policy_value_seq[i].pvalue.get_buffer (); - + TAO_InputCDR in_CDR (ACE_reinterpret_cast (const char*, buf), policy_value_seq[i].pvalue.length ()); - + in_CDR >> ACE_InputCDR::to_boolean (byte_order); in_CDR.reset_byte_order (ACE_static_cast(int, byte_order)); @@ -175,12 +193,33 @@ TAO_Profile::policies (void) // policies that TAO doesn't support, so as specified // by the RT-CORBA spec. ptc/99-05-03 we just ignore // this un-understood policies. + // @@ Angelo: in this case we may still want to log + // the problem (just use ACE_DEBUG right now if + // TAO_debug_level is high enough). } } } else { // @@ Marina, what should happen here? + // @@ Angelo: I find it easier to read code like this: + // + // if (!condition) + // return; // Nothing bad happenned + // foo; + // bar; + // + // than code like this: + // + // if (condition) + // { + // foo; + // bar; + // } + // specially when the numbers of <foos> and <bars> is really + // high. + // In this case I think the code would be a *lot* more + // readable if you did that. } } @@ -193,6 +232,9 @@ TAO_Profile::policies (void) void TAO_Profile::the_stub (TAO_Stub *stub) { + // @@ Angelo: Can the stub for a profile change? When? What about + // race conditions? If it cannot change: shouldn't it be set in the + // constructor or something? this->stub_ = stub; } diff --git a/TAO/tao/RT_Policy_i.cpp b/TAO/tao/RT_Policy_i.cpp index 03deb6e227f..d30df7959dd 100644 --- a/TAO/tao/RT_Policy_i.cpp +++ b/TAO/tao/RT_Policy_i.cpp @@ -85,6 +85,11 @@ TAO_PriorityModelPolicy::_tao_encode (TAO_OutputCDR &out_cdr) // the order specified in the RTCORBA 1.0 spec (ptc/99-05-03) // section 4.7.3. + // @@ Angelo: how is the temporary useful? What is wrong with + // + // if ((out_cdr << XXX) && (out_cdr << YYY)) + // + // ???? CORBA::Boolean b = (out_cdr << priority_model_); if (b && (out_cdr << server_priority_)) return 1; diff --git a/TAO/tao/RT_Policy_i.h b/TAO/tao/RT_Policy_i.h index 49c39a85edd..881b2b56104 100644 --- a/TAO/tao/RT_Policy_i.h +++ b/TAO/tao/RT_Policy_i.h @@ -42,6 +42,8 @@ class Policy_Factory; +// @@ Angelo: ACE's automatic documentation tools need to have all the +// base classes in the same line, I hate it too, so just fix it. class TAO_Export TAO_PriorityModelPolicy : public RTCORBA::PriorityModelPolicy, public TAO_Local_RefCounted_Object @@ -113,6 +115,9 @@ private: // Attributes. }; +// @@ Angelo: the traditional separator in ACE+TAO is // **** +// furthermore, it is better if you *don't* mix many classes in the +// same file, consider splitting this stuff. //////////////////////////////////////////////////////////////////////////// class TAO_Export TAO_ThreadpoolPolicy : @@ -604,6 +609,14 @@ protected: ////////////////////////////////////////////////////////////////////////// +// @@ Angelo: I suspect that this stuff should be moved into the +// pluggable protocol framework, to be precise: +// + Each TAO_Protocol_Factory class should be able to create a +// ProtocolProperties object. +// + The ORB should use the list of available protocols to create +// any requested protocol property. +// + class TAO_Export TAO_Protocol_Properties_Factory { public: diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index bcf5a048cb1..9f141dc9310 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -138,6 +138,8 @@ TAO_Stub::~TAO_Stub (void) #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ this->orb_core_->_decr_refcnt (); + + // @@ Angelo: you must destroy your parsed policies (if any too!) } void @@ -203,7 +205,8 @@ TAO_Stub::hash (CORBA::ULong max, // object.) // // NOTE that this must NOT go across the network! -// @@ Two object references are the same if any two profiles are the same! +// @@ Two object references are the same if any two profiles are the +// same! This function is only test the profile in use!!! CORBA::Boolean TAO_Stub::is_equivalent (CORBA::Object_ptr other_obj) { @@ -323,6 +326,10 @@ TAO_Stub::do_dynamic_call (const char *opname, int lazy_evaluation, CORBA::Environment &ACE_TRY_ENV) { + // @@ TOCCST: why do we keep using this function when ACE+TAO code + // is clearly not cancel safe anymore? Furthermore, all the + // generated code using the Invocation classes is probably not + // cancel safe! TAO_Synchronous_Cancellation_Required NOT_USED; // Do a locate_request if necessary/wanted. @@ -331,6 +338,11 @@ TAO_Stub::do_dynamic_call (const char *opname, // be forwarded. No standard way now to know. if (this->use_locate_request_ && this->first_locate_request_) { + // @@ TOCCST: notice how the locate request is only sent for + // dynamic and deferred (!!) calls, nothing is done for static + // calls, the far more common case. IMHO this should just go + // away, after all we have _validate_connection to do the same + // thing! TAO_GIOP_Locate_Request_Invocation call (this, this->orb_core_); @@ -457,7 +469,10 @@ void TAO_Stub::do_deferred_call (const CORBA::Request_ptr req, CORBA::Environment &ACE_TRY_ENV) { - + // @@ TOCCST: why do we keep using this function when ACE+TAO code + // is clearly not cancel safe anymore? Furthermore, all the + // generated code using the Invocation classes is probably not + // cancel safe! TAO_Synchronous_Cancellation_Required NOT_USED; // Do a locate_request if necessary/wanted. @@ -466,6 +481,11 @@ TAO_Stub::do_deferred_call (const CORBA::Request_ptr req, // be forwarded. No standard way now to know. if (this->use_locate_request_ && this->first_locate_request_) { + // @@ TOCCST: notice how the locate request is only sent for + // dynamic and deferred (!!) calls, nothing is done for static + // calls, the far more common case. IMHO this should just go + // away, after all we have _validate_connection to do the same + // thing! TAO_GIOP_Locate_Request_Invocation call (this, this->orb_core_); @@ -584,6 +604,9 @@ TAO_Stub::exposed_priority_model (void) this->is_priority_model_policy_parsed_ = 1; + // @@ Angelo: I think you want to use a Policy_var here! And + // avoid using <Policy*>, use Policy_ptr if you must, people read + // this code sometimes and we want them to learn good CORBA habits. CORBA::Policy *policy = this->parse_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); @@ -592,6 +615,8 @@ TAO_Stub::exposed_priority_model (void) RTCORBA::PriorityModelPolicy *pm_policy = 0; // @@ Angelo, I think there is a memory leak here. <narrow> // method creates/adds ref to object... Same applies to other methods... + // @@ Angelo: I agree, who destroys the <policy> object? And + // where do you destroy the cached policies? pm_policy = RTCORBA::PriorityModelPolicy::_narrow (policy); @@ -693,6 +718,16 @@ TAO_Stub::get_policy (CORBA::PolicyType type, // Validity check. Make sure requested policy type is appropriate // for this scope. + // @@ Angelo: is this the right exception to raise? I would thing + // that maybe CORBA::InvalidPolicies or something like that is + // what the spec requires? + // In fact, I could not find anything in the spec about raising + // exceptions while querying policies, maybe you can always query + // these policies, even at the object level, but the query just + // results in a <nil> policy returned? + // In that case the exception should only be raised when *setting* + // the policy, and that raises another exception, as specified in + // the 4.3.8 section of the spec.... if (type == RTCORBA::THREADPOOL_POLICY_TYPE || type == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE) ACE_THROW_RETURN (CORBA::NO_PERMISSION (), @@ -742,6 +777,8 @@ TAO_Stub::get_client_policy (CORBA::PolicyType type, #if (TAO_HAS_RT_CORBA == 1) + // @@ Angelo: please see my comments above... + // Validity check. Make sure requested policy type is appropriate // for this scope. if (type == RTCORBA::THREADPOOL_POLICY_TYPE @@ -811,6 +848,11 @@ TAO_Stub::set_policy_overrides (const CORBA::PolicyList & policies, CORBA::ULong slot = policy->policy_type (ACE_TRY_ENV); ACE_CHECK_RETURN (0); + // @@ Angelo: I'm almost certain that you cannot raise this + // exception here, the only one allowed by the spec is + // CORBA::InvalidPolicies, please fix it. + // BTW, please add the throw specs while you are at it. + // if (slot == RTCORBA::THREADPOOL_POLICY_TYPE || slot == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE || slot == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) @@ -876,6 +918,7 @@ TAO_Stub::get_policy_overrides (const CORBA::PolicyTypeSeq &types, { CORBA::ULong type = types[i]; + // @@ Angelo: please check the comments above. if (type == RTCORBA::THREADPOOL_POLICY_TYPE || type == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE || type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) diff --git a/TAO/tests/Exposed_Policies/Counter.idl b/TAO/tests/Exposed_Policies/Counter.idl index d204d0e5653..0e1140573ef 100644 --- a/TAO/tests/Exposed_Policies/Counter.idl +++ b/TAO/tests/Exposed_Policies/Counter.idl @@ -2,6 +2,8 @@ interface Counter { + // @@ Angelo: please add some comments explaining how does this work + // or what it is supposed to do. void increment (); long get_count (); oneway void shutdown (); diff --git a/TAO/tests/Exposed_Policies/Counter_i.cpp b/TAO/tests/Exposed_Policies/Counter_i.cpp index 7932097b318..09417dd932b 100644 --- a/TAO/tests/Exposed_Policies/Counter_i.cpp +++ b/TAO/tests/Exposed_Policies/Counter_i.cpp @@ -21,6 +21,8 @@ Counter_Servant::~Counter_Servant (void) // @@ Angelo, you are going to get warnings about unused environment // parameter in the methods below. +// @@ Angelo: you are missing all the throw specs, please fix. + void Counter_Servant::increment (CORBA::Environment &ACE_TRY_ENV) { diff --git a/TAO/tests/Exposed_Policies/Counter_i.h b/TAO/tests/Exposed_Policies/Counter_i.h index 679df096977..2ce6aec4c99 100644 --- a/TAO/tests/Exposed_Policies/Counter_i.h +++ b/TAO/tests/Exposed_Policies/Counter_i.h @@ -21,6 +21,8 @@ #include "CounterS.h" +// @@ Angelo: you are missing all the throw specs, please fix. + class Counter_Servant : public POA_Counter { public: diff --git a/TAO/tests/Exposed_Policies/RT_Properties.cpp b/TAO/tests/Exposed_Policies/RT_Properties.cpp index ce727d6c3f4..9dcfc156cab 100644 --- a/TAO/tests/Exposed_Policies/RT_Properties.cpp +++ b/TAO/tests/Exposed_Policies/RT_Properties.cpp @@ -1,4 +1,4 @@ -//$Id$ +>//$Id$ #include "RT_Properties.h" @@ -16,18 +16,19 @@ RT_Properties::~RT_Properties (void) } RT_Properties * -RT_Properties::read_from (const char *file_name, +RT_Properties::read_from (const char *file_name, CORBA::Environment &ACE_TRY_ENV) { FILE *fp = ACE_OS::fopen (file_name, "r"); - - RT_Properties *rt_properties; + + RT_Properties *rt_properties; ACE_NEW_THROW_EX (rt_properties, RT_Properties, CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_NO)); - + + // @@ Angelo: what if the length is more than 255? char string_field[256]; int int_field; unsigned int i = 0; @@ -38,7 +39,7 @@ RT_Properties::read_from (const char *file_name, fscanf (fp, "%s", string_field); rt_properties->ior_source (string_field); } - + else if (ACE_OS_String::strcmp (string_field, "Priority") == 0) { fscanf (fp, "%d", &int_field); @@ -48,21 +49,21 @@ RT_Properties::read_from (const char *file_name, { fscanf (fp, "%d", &int_field); rt_properties->priority_bands_.length (int_field); - + } else if (ACE_OS_String::strcmp (string_field, "Priority_Range") == 0) { fscanf (fp, "%d", &int_field); rt_properties->priority_bands_[i].low = int_field; - + fscanf (fp, "%d", &int_field); rt_properties->priority_bands_[i].high = int_field; - + ++i; } } - - + + return rt_properties; } @@ -72,7 +73,7 @@ RT_Properties::priority (RTCORBA::Priority priority) this->priority_ = priority; } -RTCORBA::Priority +RTCORBA::Priority RT_Properties::priority (void) { return this->priority_; @@ -84,16 +85,18 @@ RT_Properties::priority_bands (const RTCORBA::PriorityBands& priority_bands) this->priority_bands_ = priority_bands; } -const RTCORBA::PriorityBands& +const RTCORBA::PriorityBands& RT_Properties::priority_bands (void) { return this->priority_bands_; } -void +void RT_Properties::ior_source (const char *s) { + // @@ Angelo: please use strncpy() for strings like this, otherwise + // you could blow the buffer limits! ACE_OS_String::strcpy (this->ior_source_, s); } diff --git a/TAO/tests/Exposed_Policies/client.cpp b/TAO/tests/Exposed_Policies/client.cpp index 5f9d0f3d1c2..5c347530378 100644 --- a/TAO/tests/Exposed_Policies/client.cpp +++ b/TAO/tests/Exposed_Policies/client.cpp @@ -8,17 +8,13 @@ char object_ref[256]; ACE_RCSID(tao, client, "$Id$") - CORBA::Boolean check_reference (CORBA::Object_ptr object, - const char *msg = 0) +CORBA::Boolean +check_reference (CORBA::Object_ptr object, + const char *msg) { if (CORBA::is_nil (object)) { - if (msg == 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("The Object reference is nil.\n"))); - else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (msg))); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (msg))); return 0; } return 1; @@ -33,9 +29,16 @@ main (int argc, char *argv[]) ACE_TRY { // ORB Initialization - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "TAO", ACE_TRY_ENV); + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "TAO", ACE_TRY_ENV); + // @@ Angelo: there is no need to name the ORB, don't do it + // unless you have a good reason to, because it confuses the + // users that see this stuff. ACE_TRY_CHECK; - + + // @@ Angelo: we have been using -k IOR for this same kind of + // option forever, please try to make your examples consistent, + // it is easier to understand them that way. ACE_Arg_Shifter arg_shifter (argc, argv); int file_set = 0; @@ -53,78 +56,99 @@ main (int argc, char *argv[]) else arg_shifter.consume_arg (); } - + if (file_set == 0) ACE_OS_String::strcpy (object_ref, "file://poa_default.ior"); + // @@ Angelo: it is better style just to initialize the + // variables as soon as you declare them, in this case: + // + // CORBA::Object_var object = orb->string_to_object_.... + // CORBA::Object_var object; + // @@ Angelo: you may want to repeat the test multiple times in + // a loop, this is useful when running with Purify or similar + // tools because the leaks are more visible when you do that. + + // @@ Angelo: I'm not sure if you really need a client and a + // server, it may be enough to have a single program that does + // object_to_string() and then string_to_object() to verify that + // all the policies are preserved and parsed correctly. Those + // programs are usually much easier to debug and purify. + // Get the IOR from a file. object = orb->string_to_object (object_ref, ACE_TRY_ENV); ACE_TRY_CHECK; + // @@ Angelo: cool use of a helper routine, but you may want to + // declare the helper at the top of the file and put its + // definition at the bottom, to avoid distractions when looking + // for the core of the test. if (!check_reference (object, "Invalid IOR file!\n")) return 1; - + Counter_var counter = Counter::_narrow (object.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - - if (!check_reference (object, + + if (!check_reference (object, "Unable to convert the IOR to the proper object reference.\n")) return 1; - + + // @@ Angelo: more initialization stuff. CORBA::Policy_var policy_ptr; policy_ptr = counter->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE, ACE_TRY_ENV); ACE_TRY_CHECK; - + if (check_reference (policy_ptr, "Unable to get Priority Policy.\n")) { RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy_ptr); - - RTCORBA::PriorityModel priority_model = + + RTCORBA::PriorityModel priority_model = priority_policy->priority_model (ACE_TRY_ENV); ACE_TRY_CHECK; - - RTCORBA::Priority priority = + + RTCORBA::Priority priority = priority_policy->server_priority (ACE_TRY_ENV); ACE_TRY_CHECK; - + if (priority_model == RTCORBA::SERVER_DECLARED) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\nPriority Model: RTCORBA::SERVER_DECLARED\n") )); - - ACE_DEBUG ((LM_DEBUG, + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Priority Model: %d\nCORBA Priority: %d\n\n"), priority_model, priority )); } - + policy_ptr = object->_get_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE, ACE_TRY_ENV); if (check_reference (policy_ptr, "Unable to get Priority Banded Policy\n")) { - - RTCORBA::PriorityBandedConnectionPolicy_var priority_banded_policy = + + RTCORBA::PriorityBandedConnectionPolicy_var priority_banded_policy = RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy_ptr, ACE_TRY_ENV); ACE_TRY_CHECK; - - + + if (check_reference (priority_banded_policy, "Unable to get Priority Banded Policy\n")) { - + // Here we have a priority banded connection policy. - - RTCORBA::PriorityBands_var pb = priority_banded_policy->priority_bands (); + + RTCORBA::PriorityBands_var pb = + priority_banded_policy->priority_bands (); unsigned int band_num = pb->length (); for (unsigned int i = 0; i < band_num; ++i) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Priority Band <%d>: (%d, %d)\n"), + ACE_TEXT ("Priority Band <%d>: (%d, %d)\n"), i, pb[i].low, pb[i].high @@ -136,20 +160,32 @@ main (int argc, char *argv[]) ACE_TRY_ENV); if (check_reference (policy_ptr, "Unable Client Protocol Policy\n")) { - RTCORBA::ClientProtocolPolicy_var client_protocol_policy = + RTCORBA::ClientProtocolPolicy_var client_protocol_policy = RTCORBA::ClientProtocolPolicy::_narrow (policy_ptr, ACE_TRY_ENV); ACE_TRY_CHECK; - - RTCORBA::ProtocolList_var protocol_list = + + RTCORBA::ProtocolList_var protocol_list = client_protocol_policy->protocols (ACE_TRY_ENV); ACE_TRY_CHECK; - + for (unsigned int i = 0; i < protocol_list->length (); i++) ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\nThe Client Protocol Type: %d\n"), - protocol_list[ i].protocol_type)); - + ACE_TEXT ("\nThe Client Protocol Type: %d\n"), + protocol_list[i].protocol_type)); + } + + // @@ Angelo: cleanup the ORB at the end! + + // @@ Angelo: in general this is a good test, but it does not + // check if: + // + The values obtained are the expected values, could you + // compare against well known values somehow? + // + Can you check that things that should fail indeed do? For + // example: what if the user queries or tries to set a policy + // that makes no sense, like Timeouts? Certain values should + // be returned and maybe exceptions raised (I don't know), we + // need to check for that too! } ACE_CATCHANY { diff --git a/TAO/tests/Exposed_Policies/server.cpp b/TAO/tests/Exposed_Policies/server.cpp index 4093a237a82..94931085a88 100644 --- a/TAO/tests/Exposed_Policies/server.cpp +++ b/TAO/tests/Exposed_Policies/server.cpp @@ -7,29 +7,35 @@ // - ClientProtocolPolicy // // This policies are embedded in the object reference, by writem -// them into the IOR. +// them into the IOR. // // #include "Counter_i.h" + +// @@ Angelo, we don't use angle brackets in our tests or examples +// because that disables dependencies, we need to have the code +// automatically compile if something fails. #include <tao/RT_ORB.h> #include <tao/RT_Policy_i.h> #include <ace/Arg_Shifter.h> +// @@ Angelo: any reason to have an inconsistent order of declaration? #include "RT_Properties.h" ACE_RCSID(tao, server, "$Id$"); - +// @@ Angelo: please move this routine to some common place (but *NOT* +// in the TAO library). CORBA::Boolean check_reference (CORBA::Object_ptr object, const char *msg = 0) { if (CORBA::is_nil (object)) { if (msg == 0) - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("The Object reference is nil.\n"))); else - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT (msg))); return 0; } @@ -50,9 +56,9 @@ main (int argc, char *argv[]) // Here we parse the command line paramether passed // to the application. - + ACE_Arg_Shifter arg_shifter (argc, argv); - + RT_Properties *rt_object_properties = 0; RT_Properties *rt_poa_properties = 0; @@ -70,25 +76,25 @@ main (int argc, char *argv[]) rt_object_properties = RT_Properties::read_from (arg, ACE_TRY_ENV); ACE_TRY_CHECK; } - else + else arg_shifter.consume_arg (); - - } - + + } + CORBA::Object_var object; - + // Get a reference to the RT-ORB. object = orb->resolve_initial_references ("RTORB", ACE_TRY_ENV); ACE_TRY_CHECK; - + RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - + CORBA::PolicyList poa_policy_list; poa_policy_list.length (3); - - + + // Create the priority policy using the RT-ORB. RTCORBA::Priority priority = rt_poa_properties->priority (); poa_policy_list[0] = @@ -96,21 +102,21 @@ main (int argc, char *argv[]) priority, ACE_TRY_ENV); ACE_TRY_CHECK; - + // Create priority Banded Connection Policy. RTCORBA::PriorityBands poa_priority_bands = rt_poa_properties->priority_bands (); - - poa_policy_list[1] = - rt_orb->create_priority_banded_connection_policy (poa_priority_bands, + + poa_policy_list[1] = + rt_orb->create_priority_banded_connection_policy (poa_priority_bands, ACE_TRY_ENV); ACE_TRY_CHECK; - + // Client Protocol Policy. RTCORBA::ProtocolList protocol_list; protocol_list.length (1); - + protocol_list[0].protocol_type = IOP::TAG_INTERNET_IOP; - protocol_list[0].orb_protocol_properties = + protocol_list[0].orb_protocol_properties = TAO_Protocol_Properties_Factory::create_orb_protocol_property (IOP::TAG_INTERNET_IOP); protocol_list[0].transport_protocol_properties = @@ -121,19 +127,19 @@ main (int argc, char *argv[]) object = orb->resolve_initial_references ("RootPOA", ACE_TRY_ENV); ACE_TRY_CHECK; - + PortableServer::POA_var poa = PortableServer::POA::_narrow (object.in (), ACE_TRY_ENV); ACE_TRY_CHECK; PortableServer::POAManager_var poa_mgr = PortableServer::POAManager::_nil (); - + PortableServer::POA_var child_poa = poa->create_POA ("Child_POA", poa_mgr , poa_policy_list); - + // Create a Corba Object reference, using the policies // set at the POA level. object = @@ -141,17 +147,17 @@ main (int argc, char *argv[]) ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Reference Created!\n"))); - if (!check_reference (object, + if (!check_reference (object, "Unable to create a Counter Object!\n")) return 1; Counter_var counter = Counter::_narrow (object.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - - if (!check_reference (counter.in(), + + if (!check_reference (counter.in(), "Unable to create a Counter Object!\n")) return 1; @@ -163,7 +169,7 @@ main (int argc, char *argv[]) orb->object_to_string (counter.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Activated as <%s>\n"), ior.in ())); FILE *output_file = ACE_OS::fopen (rt_poa_properties->ior_source (), "w"); @@ -174,45 +180,45 @@ main (int argc, char *argv[]) 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); - + // Now we create an object that overrides some of the policies // set at the POA level. // Create a Corba Object reference, using the policies // set at the POA level. - - // @@ Shortcut - The following code is not definitive, and + + // @@ Shortcut - The following code is not definitive, and // the cast is only used to access a RTPortableServer::POA // method that isn't currently accessible otherwise. - + object = ((TAO_POA*)child_poa.ptr ())->create_reference_with_priority ("IDL:Counter:1.0", rt_object_properties->priority (), ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Reference Created!\n"))); - if (!check_reference (object, + if (!check_reference (object, "Unable to create a Counter Object!\n")) return 1; Counter_var counter_over = Counter::_narrow (object.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - - if (!check_reference (counter_over.in(), + + if (!check_reference (counter_over.in(), "Unable to create a Counter Object!\n")) return 1; - + CORBA::String_var o_ior = orb->object_to_string (counter_over.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Activated as <%s>\n"), o_ior.in ())); - + output_file = ACE_OS::fopen (rt_object_properties->ior_source (), "w"); if (output_file == 0) @@ -240,7 +246,7 @@ main (int argc, char *argv[]) ACE_CATCHANY { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, ACE_TEXT ("CORBA Exception Raised.")); return 1; } @@ -248,4 +254,3 @@ main (int argc, char *argv[]) return 0; } - |