void TAO_POA_Policy_Set::validate_policies (TAO_Policy_Validator &validator, TAO_ORB_Core &orb_core) { // Just give a last chance for all the unloaded validators in other // libraries to be registered orb_core.load_policy_validators (validator); // Validate that all of the specified policies make sense. validator.validate (this->impl_ ); // Verify that all policies are legal for the currently loaded // POA extensions. for (CORBA::ULong i = 0; i < this->impl_.num_policies (); i++) { CORBA::Policy_var policy = this->impl_.get_policy_by_index (i); CORBA::PolicyType type = policy->policy_type (); if (!(validator.legal_policy (type))) { #if !defined (CORBA_E_MICRO) // An invalid policy was specified. Let the user know about // it. throw PortableServer::POA::InvalidPolicy (); #else TAOLIB_ERROR ((LM_ERROR, "Invalid policy\n")); #endif } } }
void IORInterceptor::establish_components ( PortableInterceptor::IORInfo_ptr info) { try { PortableInterceptor::ObjectReferenceTemplate_var t = info->adapter_template (); PortableInterceptor::AdapterName_var a = t->adapter_name (); // Only execute if POA is not RootPOA. The RootPOA will not // have our custom policy, but the child POA we created will. if (a->length () > 1) { CORBA::Policy_var policy ( info->get_effective_policy (Test::POLICY_TYPE)); Test::Policy_var test_policy (Test::Policy::_narrow ( policy.in ())); this->success_ = true; } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "EXCEPTION: ""IORInterceptor::establish_components:"); ACE_ASSERT (false); } }
int insecure_invocation_test (CORBA::ORB_ptr orb, CORBA::Object_ptr obj) { // Disable protection for this insecure invocation test. Security::QOP qop = Security::SecQOPNoProtection; CORBA::Any no_protection; no_protection <<= qop; // Create the Security::QOPPolicy. CORBA::Policy_var policy = orb->create_policy (Security::SecQOPPolicy, no_protection); CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = CORBA::Policy::_duplicate (policy.in ()); // Create an object reference that uses plain IIOP (i.e. no // protection). CORBA::Object_var object = obj->_set_policy_overrides (policy_list, CORBA::SET_OVERRIDE); Foo::Bar_var server = Foo::Bar::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Object reference <%s> is " "nil.\n", ior)); return 1; } try { // This invocation should result in a CORBA::NO_PERMISSION // exception. server->baz (); } catch (const CORBA::NO_PERMISSION&) { ACE_DEBUG ((LM_INFO, "(%P|%t) Received CORBA::NO_PERMISSION from " "server, as expected.\n")); return 0; } ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: CORBA::NO_PERMISSION was not thrown.\n" "(%P|%t) ERROR: It should have been thrown.\n")); return 1; }
//Check if the policy of object is set to client declared CORBA::Short check_cp_policy (Test_ptr server ACE_ENV_ARG_DECL) { // Check that the object is configured with CLIENT_PROPAGATED // PriorityModelPolicy. CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (CORBA::is_nil (priority_policy.in ())) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Priority Model Policy not exposed!\n"), -1); RTCORBA::PriorityModel priority_model = priority_policy->priority_model (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (priority_model != RTCORBA::CLIENT_PROPAGATED) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: priority_model != " "RTCORBA::CLIENT_PROPAGATED!\n"), -1); return priority_policy->server_priority (ACE_ENV_SINGLE_ARG_PARAMETER); }
void TAO_RT_POA::parse_rt_policies (TAO_POA_Policy_Set &policies) { { CORBA::Policy_var policy = policies.get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL); RTCORBA::PriorityModelPolicy_var priority_model = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (!CORBA::is_nil (priority_model.in ())) { RTCORBA::PriorityModel rt_priority_model = priority_model->priority_model (); this->cached_policies_.priority_model ( TAO::Portable_Server::Cached_Policies::PriorityModel (rt_priority_model)); RTCORBA::Priority priority = priority_model->server_priority (); this->cached_policies_.server_priority (priority); } } this->thread_pool_ = TAO_POA_RT_Policy_Validator::extract_thread_pool (this->orb_core_, policies.policies ()); }
bool ClientTest::non_secure_invocation () { ACE_DEBUG ((LM_DEBUG, "mixed_security/client: invoking via non-secured means\n")); // Disable protection for this insecure invocation test. Security::QOP qop = Security::SecQOPNoProtection; CORBA::Any no_protection; no_protection <<= qop; // Create the Security::QOPPolicy. CORBA::Policy_var policy = this->orb_->create_policy (Security::SecQOPPolicy, no_protection); CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = CORBA::Policy::_duplicate (policy.in ()); // Create an object reference that uses plain IIOP (i.e. no // protection). CORBA::Object_var object = this->obj_->_set_policy_overrides (policy_list, CORBA::SET_OVERRIDE); Foo::Bar_var server = Foo::Bar::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Failed to narrow override reference to " "Foo::Bar type.\n")); throw CORBA::INTERNAL (); } bool invocation_succeeded = true; try { // This invocation should result in a CORBA::NO_PERMISSION // exception. server->baz (); ACE_DEBUG ((LM_DEBUG, "mixed_security/client: non-secured invocation succeeded\n")); } catch (const CORBA::NO_PERMISSION& ) { ACE_DEBUG ((LM_DEBUG, "ClientTest::non_secure_invocation: got NO_PERMISSION\n")); invocation_succeeded = false; } return invocation_succeeded; }
void Cached_Policies::update (TAO_POA_Policy_Set &policy_set ) { for (CORBA::ULong i = 0; i < policy_set.num_policies (); i++) { CORBA::Policy_var policy = policy_set.get_policy_by_index (i); this->update_policy (policy.in () ); } }
void TAO_ZIOPPolicy_Validator::validate_impl (TAO_Policy_Set &policies) { CORBA::Policy_var policy = policies.get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); if (policy.in () == 0) return; ZIOP::CompressionEnablingPolicy_var srp = ZIOP::CompressionEnablingPolicy::_narrow (policy.in ()); if (srp.in () == 0) return; }
CORBA::Policy_ptr TAO_Stub::get_cached_policy (TAO_Cached_Policy_Type type) { // No need to lock, the stub only changes its policies at // construction time... CORBA::Policy_var result; if (this->policies_ != 0) { result = this->policies_->get_cached_policy (type); } if (CORBA::is_nil (result.in ())) { result = this->orb_core_->get_cached_policy_including_current (type); } return result._retn (); }
CORBA::Policy_ptr TAO_IORInfo::get_effective_policy (CORBA::PolicyType type) { this->check_validity (); CORBA::Policy_var policy = this->poa_->get_policy (type); if (!CORBA::is_nil (policy.in ())) { return policy._retn (); } // TODO: Now check the global ORB policies. // ........ // No policy matching the given PolicyType was found. throw ::CORBA::INV_POLICY (CORBA::OMGVMCID | 3, CORBA::COMPLETED_NO); }
CORBA::Object_ptr register_with_proxy (CORBA::Object_ptr native) { // Disable protection for this insecure invocation test. Security::QOP qop = Security::SecQOPNoProtection; CORBA::Any no_protection; no_protection <<= qop; // Create the Security::QOPPolicy. CORBA::Policy_var policy = orb->create_policy (Security::SecQOPPolicy, no_protection); CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = CORBA::Policy::_duplicate (policy.in ()); // Create an object reference that uses plain IIOP (i.e. no // protection). CORBA::Object_var object = mapper->_set_policy_overrides (policy_list, CORBA::SET_OVERRIDE); ACE_DEBUG ((LM_DEBUG,"Trying to narrow an insecure reference\n")); Lorica::ReferenceMapper_var open_mapper = Lorica::ReferenceMapper::_narrow(object.in()); ACE_DEBUG ((LM_DEBUG,"Using open mapper for registering\n")); try { return open_mapper->as_server(native,"Hello", Lorica::ServerAgent::_nil()); } catch (CORBA::Exception &ex) { ACE_DEBUG ((LM_DEBUG,"open_mapper->as_server raised %s\n",ex._name())); return CORBA::Object::_nil(); } }
CORBA::Short Activity::get_server_priority (CORBA::Object_ptr server) { // Get the Priority Model Policy from the stub. CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); // Narrow down to correct type. RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); // Make sure that we have the SERVER_DECLARED priority model. RTCORBA::PriorityModel priority_model = priority_policy->priority_model (); if (priority_model != RTCORBA::SERVER_DECLARED) return -1; // Return the server priority. return priority_policy->server_priority (); }
void TAO_POA_Policy_Set::add_client_exposed_fixed_policies ( CORBA::PolicyList *client_exposed_policies) { CORBA::ULong cep_index = client_exposed_policies->length (); for (CORBA::ULong i = 0; i < this->num_policies (); ++i) { CORBA::Policy_var policy = this->get_policy_by_index (i); // If this policy is client exposed, add it to the list. if (policy->_tao_scope () & TAO_POLICY_CLIENT_EXPOSED) { client_exposed_policies->length (cep_index + 1); (*client_exposed_policies)[cep_index] = policy->copy (); ++cep_index; } } }
CORBA::Short check_policy (Test_ptr server) { CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1) return -1; RTCORBA::PriorityModel priority_model = priority_policy->priority_model (); if (priority_model != RTCORBA::SERVER_DECLARED) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: priority_model != " "RTCORBA::SERVER_DECLARED!\n"), -1); return priority_policy->server_priority (); }
/* static */ TAO_Thread_Pool * TAO_POA_RT_Policy_Validator::extract_thread_pool (TAO_ORB_Core &orb_core, TAO_Policy_Set &policies) { CORBA::Policy_var policy = policies.get_cached_policy (TAO_CACHED_POLICY_THREADPOOL); RTCORBA::ThreadpoolPolicy_var thread_pool_policy = RTCORBA::ThreadpoolPolicy::_narrow (policy.in ()); if (CORBA::is_nil (thread_pool_policy.in ())) return 0; RTCORBA::ThreadpoolId thread_pool_id = thread_pool_policy->threadpool (); // Get the RTORB. CORBA::Object_var object = orb_core.resolve_rt_orb (); RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); TAO_RT_ORB * const tao_rt_orb = dynamic_cast <TAO_RT_ORB *> (rt_orb.in ()); if (!tao_rt_orb) throw CORBA::INTERNAL (); TAO_Thread_Pool_Manager & tp_manager = tao_rt_orb->tp_manager (); TAO_Thread_Pool * const thread_pool = tp_manager.get_threadpool (thread_pool_id); if (thread_pool == 0) throw PortableServer::POA::InvalidPolicy (); return thread_pool; }
//Check if the policy of object is set to server declared CORBA::Short check_sd_policy (Test_ptr server ACE_ENV_ARG_DECL) { CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1) return -1; RTCORBA::PriorityModel priority_model = priority_policy->priority_model (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); if (priority_model != RTCORBA::SERVER_DECLARED) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: priority_model != " "RTCORBA::SERVER_DECLARED!\n"), -1); return priority_policy->server_priority (ACE_ENV_SINGLE_ARG_PARAMETER); }
int TAO_DiffServ_Service_Context_Handler::generate_service_context ( TAO_Stub *stub, TAO_Transport&, TAO_Operation_Details &opdetails, TAO_Target_Specification &, TAO_OutputCDR &) { if (stub) { CORBA::Policy_var cnpp = stub->get_cached_policy (TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY); TAO::NetworkPriorityPolicy_var cnp = TAO::NetworkPriorityPolicy::_narrow (cnpp.in ()); if (!CORBA::is_nil (cnp.in ())) { TAO::DiffservCodepoint const reply_diffserv_codepoint = cnp->reply_diffserv_codepoint (); CORBA::Long const rep_dscp_codepoint = reply_diffserv_codepoint; TAO_OutputCDR cdr; if (!(cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) || !(cdr << rep_dscp_codepoint)) { throw CORBA::MARSHAL (); } opdetails.request_service_context ().set_context (IOP::REP_NWPRIORITY, cdr); } } return 0; }
void TAO_DiffServ_Network_Priority_Hook::update_network_priority ( TAO_Root_POA &poa, TAO_POA_Policy_Set &policy_set) { for (CORBA::ULong i = 0; i < policy_set.num_policies (); i++) { CORBA::Policy_var policy = policy_set.get_policy_by_index (i); if (policy->policy_type () == TAO::NETWORK_PRIORITY_TYPE) { ::TAO::NetworkPriorityPolicy_var npp = ::TAO::NetworkPriorityPolicy::_narrow (policy.in ()); if (!CORBA::is_nil (npp.in ())) { TAO::NetworkPriorityModel network_priority_model = npp->network_priority_model (); poa.cached_policies ().network_priority_model ( TAO::Portable_Server::Cached_Policies::NetworkPriorityModel ( network_priority_model)); TAO::DiffservCodepoint request_diffserv_codepoint = npp->request_diffserv_codepoint (); TAO::DiffservCodepoint reply_diffserv_codepoint = npp->reply_diffserv_codepoint (); poa.cached_policies ().request_diffserv_codepoint ( request_diffserv_codepoint); poa.cached_policies ().reply_diffserv_codepoint ( reply_diffserv_codepoint); } } } }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init( argc, argv ); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var obj = orb->string_to_object( ior ); Messenger_var messenger = Messenger::_narrow( obj.in() ); CORBA::String_var message = CORBA::string_dup( "Terminating messenger service!" ); messenger->send_message( "Chief of Security", "New Directive", message.inout() ); messenger->shutdown("Chief of Security"); Security::QOP qop = Security::SecQOPIntegrityAndConfidentiality; CORBA::Any want_protection; want_protection <<= qop; CORBA::Policy_var policy = orb->create_policy (Security::SecQOPPolicy, want_protection); Security::EstablishTrust establish_trust; establish_trust.trust_in_client = 0; establish_trust.trust_in_target = 1; CORBA::Any want_trust; want_trust <<= establish_trust; CORBA::Policy_var policy2 = orb->create_policy (Security::SecEstablishTrustPolicy, want_trust); CORBA::PolicyList policy_list (2); policy_list.length (1); policy_list[0] = CORBA::Policy::_duplicate (policy.in ()); policy_list.length (2); policy_list[1] = CORBA::Policy::_duplicate (policy2.in ()); CORBA::Object_var object = obj->_set_policy_overrides (policy_list, CORBA::SET_OVERRIDE); Messenger_var messenger2 = Messenger::_narrow( object.in() ); message = CORBA::string_dup( "Terminating messenger service!" ); messenger2->send_message( "Chief of Security", "New Directive", message.inout() ); messenger2->shutdown("Chief of Security"); orb->destroy(); } catch(const CORBA::Exception& ex) { ex._tao_print_exception("Client: main block"); return 1; } return 0; }
void TAO_POA_RT_Policy_Validator::validate_priorities (TAO_Policy_Set &policies) { // Initialize to the default priority/priority model. CORBA::Short priority = TAO_INVALID_PRIORITY; TAO::Portable_Server::Cached_Policies::PriorityModel rt_priority_model = TAO::Portable_Server::Cached_Policies::NOT_SPECIFIED; CORBA::Policy_var policy = policies.get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL); RTCORBA::PriorityModelPolicy_var priority_model = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (!CORBA::is_nil (priority_model.in ())) { priority = priority_model->server_priority (); rt_priority_model = TAO::Portable_Server::Cached_Policies::PriorityModel ( priority_model->priority_model ()); // Check that the priority is in bounds. if (priority < RTCORBA::minPriority // The line below will always be false unless the value of // RTCORBA::maxPriority, which is now assigned the value of // 32767, is changed in RTCORBA.pidl. // || priority > RTCORBA::maxPriority ) { throw PortableServer::POA::InvalidPolicy (); } } else // If priority model was not specified, then we better not have a // thread pool with lanes. { if (this->thread_pool_ != 0 && this->thread_pool_->with_lanes ()) throw PortableServer::POA::InvalidPolicy (); } policy = policies.get_cached_policy (TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION); RTCORBA::PriorityBandedConnectionPolicy_var priority_bands = RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy.in ()); TAO_PriorityBandedConnectionPolicy *bands_policy = dynamic_cast<TAO_PriorityBandedConnectionPolicy *> (priority_bands.in ()); // If priority banded connections are set, make sure that: // 0. A priority model was specified. // 1. There is at least one band. // 2a. low is not < RTCORBA::minPriority // 2b. low <= high // 2c. high is not > RTCORBA::maxPriority // 3. If priority model is SERVER_DECLARED, server_priority must // match one of the bands. // 4. If this POA has a thread pool with lanes, then for each band, // there must be at least one thread lane that can service it, // i.e., whose priority falls into the band's range. if (bands_policy != 0) { // Checks 0. if (rt_priority_model == TAO::Portable_Server::Cached_Policies::NOT_SPECIFIED) throw PortableServer::POA::InvalidPolicy (); RTCORBA::PriorityBands &bands = bands_policy->priority_bands_rep (); // Checks 1. if (bands.length () == 0) throw PortableServer::POA::InvalidPolicy (); // Checks 2. for (CORBA::ULong i = 0; i < bands.length (); ++i) { // 2a. low is not < RTCORBA::minPriority // 2b. low is not > high // 2c. high is not > RTCORBA::maxPriority if (bands[i].low < RTCORBA::minPriority || bands[i].low > bands[i].high // The line below will always be false unless the value of // RTCORBA::maxPriority, which is now assigned the value of // 32767, is changed in RTCORBA.pidl. // || bands[i].high > RTCORBA::maxPriority ) { throw PortableServer::POA::InvalidPolicy (); } } // Check 3. if (rt_priority_model == TAO::Portable_Server::Cached_Policies::SERVER_DECLARED) { int match = 0; for (CORBA::ULong i = 0; i < bands.length (); ++i) { if (priority <= bands[i].high && priority >= bands[i].low) { match = 1; break; } } if (!match) throw PortableServer::POA::InvalidPolicy (); } // // Check 4. // // If this POA is using the default thread pool (which doesn't // have lanes) or a thread pool without lanes, we are done with // the checks. if (this->thread_pool_ == 0 || !this->thread_pool_->with_lanes ()) return; // If this POA is using a thread pool with lanes, make sure we // have at least one thread lane that corresponds to these // each band. TAO_Thread_Lane **lanes = this->thread_pool_->lanes (); for (CORBA::ULong band = 0; band < bands.length (); ++band) { int match = 0; for (CORBA::ULong lane = 0; lane != this->thread_pool_->number_of_lanes () && !match; ++lane) { CORBA::Short lane_priority = lanes[lane]->lane_priority (); if (lane_priority <= bands[band].high && lane_priority >= bands[band].low) match = 1; } if (!match) throw PortableServer::POA::InvalidPolicy (); } // Done with checks. return; } // If priority banded connections are not set, and the priority // model is SERVER_DECLARED, make sure we have at least one thread // lane that can provide service for the specified SERVER_DECLARED // priority. if (rt_priority_model == TAO::Portable_Server::Cached_Policies::SERVER_DECLARED) { // If this POA is using the default thread pool (which doesn't // have lanes) or a thread pool without lanes, we are done with // the checks. if (this->thread_pool_ == 0 || !this->thread_pool_->with_lanes ()) return; // If this POA is using a thread pool with lanes, make sure we // have at least one thread lane that can provide service for // the specified SERVER_DECLARED priority. TAO_Thread_Lane **lanes = this->thread_pool_->lanes (); int match = 0; for (CORBA::ULong lane = 0; lane != this->thread_pool_->number_of_lanes () && !match; ++lane) { CORBA::Short lane_priority = lanes[lane]->lane_priority (); if (lane_priority <= priority && lane_priority >= priority) match = 1; } if (!match) throw PortableServer::POA::InvalidPolicy (); // Done with checks. return; } }
void TAO_POA_Default_Policy_Validator::validate_impl (TAO_Policy_Set &policies) { #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) CORBA::Policy_var policy = policies.get_cached_policy (TAO_CACHED_POLICY_SERVANT_RETENTION); PortableServer::ServantRetentionPolicy_var srp = PortableServer::ServantRetentionPolicy::_narrow (policy.in ()); PortableServer::ServantRetentionPolicyValue servant_retention = srp->value (); policy = policies.get_cached_policy (TAO_CACHED_POLICY_REQUEST_PROCESSING); PortableServer::RequestProcessingPolicy_var rpp = PortableServer::RequestProcessingPolicy::_narrow (policy.in ()); PortableServer::RequestProcessingPolicyValue request_processing = rpp->value (); // The NON_RETAIN policy requires either the USE_DEFAULT_SERVANT or // USE_SERVANT_MANAGER policies. if (servant_retention == PortableServer::NON_RETAIN) if (request_processing != PortableServer::USE_SERVANT_MANAGER && request_processing != PortableServer::USE_DEFAULT_SERVANT) throw PortableServer::POA::InvalidPolicy (); // USE_ACTIVE_OBJECT_MAP_ONLY requires the RETAIN policy. if (request_processing == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) if (servant_retention != PortableServer::RETAIN) throw PortableServer::POA::InvalidPolicy (); policy = policies.get_cached_policy (TAO_CACHED_POLICY_ID_UNIQUENESS); PortableServer::IdUniquenessPolicy_var iup = PortableServer::IdUniquenessPolicy::_narrow (policy.in ()); PortableServer::IdUniquenessPolicyValue id_uniqueness = iup->value (); policy = policies.get_cached_policy (TAO_CACHED_POLICY_IMPLICIT_ACTIVATION); PortableServer::ImplicitActivationPolicy_var iap = PortableServer::ImplicitActivationPolicy::_narrow (policy.in ()); PortableServer::ImplicitActivationPolicyValue implicit_activation = iap->value (); policy = policies.get_cached_policy (TAO_CACHED_POLICY_ID_ASSIGNMENT); PortableServer::IdAssignmentPolicy_var idap = PortableServer::IdAssignmentPolicy::_narrow (policy.in ()); PortableServer::IdAssignmentPolicyValue id_assignment = idap->value (); // USE_DEFAULT_SERVANT requires the MULTIPLE_ID policy. if (request_processing == PortableServer::USE_DEFAULT_SERVANT) if (id_uniqueness != PortableServer::MULTIPLE_ID) throw PortableServer::POA::InvalidPolicy (); // IMPLICIT_ACTIVATION requires the SYSTEM_ID and RETAIN policies. if (implicit_activation == PortableServer::IMPLICIT_ACTIVATION) if (servant_retention != PortableServer::RETAIN || id_assignment != PortableServer::SYSTEM_ID) throw PortableServer::POA::InvalidPolicy (); #else /* TAO_HAS_MINIMUM_POA == 0 */ ACE_UNUSED_ARG (policies); #endif /* TAO_HAS_MINIMUM_POA == 0 */ }
void TAO_RT_POA::validate_priority (RTCORBA::Priority priority) { if (priority < RTCORBA::minPriority // The line below will always be false unless the value of // RTCORBA::maxPriority, which is now assigned the value of // 32767, is changed in RTCORBA.pidl. // || priority > RTCORBA::maxPriority ) { throw ::CORBA::BAD_PARAM (); } // If this POA is using a thread pool with lanes, make sure the // priority matches one of the thread lanes. Note that in this // case, bands do not matter since matching the lanes priority is a // stricter condition than meeting the band ranges. In addition, // when the POA was created, the bands had to match the lanes. if (this->thread_pool_ != 0 && this->thread_pool_->with_lanes ()) { TAO_Thread_Lane **lanes = this->thread_pool_->lanes (); for (CORBA::ULong i = 0; i != this->thread_pool_->number_of_lanes (); ++i) { if (lanes[i]->lane_priority () == priority) return; } throw ::CORBA::BAD_PARAM (); } else // Else we are dealing with a thread pool without lanes. { // Check if we have bands. CORBA::Policy_var bands = this->policies ().get_cached_policy ( TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION); RTCORBA::PriorityBandedConnectionPolicy_var priority_bands = RTCORBA::PriorityBandedConnectionPolicy::_narrow (bands.in ()); TAO_PriorityBandedConnectionPolicy *priority_bands_i = dynamic_cast <TAO_PriorityBandedConnectionPolicy *> (priority_bands.in ()); if (priority_bands_i) { // If we do have bands, make sure that the priority is // matching one of the bands. RTCORBA::PriorityBands &bands = priority_bands_i->priority_bands_rep (); for (CORBA::ULong i = 0; i < bands.length (); ++i) { if (bands[i].low <= priority && bands[i].high >= priority) return; } throw ::CORBA::BAD_PARAM (); } } }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB first. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (object.in ()); /* * The following code should be reenabled once the OMG spec has * been fixed such that a RTCORBA::PriorityModelPolicy can be * created by using the ORB::create_policy interface. * { RTCORBA::PriorityModelPolicy_var policy1 = rtorb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, RTCORBA::minPriority); CORBA::Any policy_value; policy_value <<= RTCORBA::CLIENT_PROPAGATED; policy_value <<= RTCORBA::minPriority; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE, policy_value); RTCORBA::PriorityModelPolicy_var policy2 = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); ACE_ASSERT (policy1->priority_model () == policy2->priority_model ()); ACE_ASSERT (policy1->server_priority () == policy2->server_priority ()); } */ { RTCORBA::ThreadpoolId poolid = 0; RTCORBA::ThreadpoolPolicy_var policy1 = rtorb->create_threadpool_policy (poolid); CORBA::Any policy_value; policy_value <<= poolid; CORBA::Policy_var policy = orb->create_policy (RTCORBA::THREADPOOL_POLICY_TYPE, policy_value); RTCORBA::ThreadpoolPolicy_var policy2 = RTCORBA::ThreadpoolPolicy::_narrow (policy.in ()); ACE_ASSERT (policy1->threadpool () == policy2->threadpool ()); } { RTCORBA::ProtocolList empty_protocols; RTCORBA::ServerProtocolPolicy_var policy1 = rtorb->create_server_protocol_policy (empty_protocols); CORBA::Any policy_value; policy_value <<= empty_protocols; CORBA::Policy_var policy = orb->create_policy (RTCORBA::SERVER_PROTOCOL_POLICY_TYPE, policy_value); RTCORBA::ServerProtocolPolicy_var policy2 = RTCORBA::ServerProtocolPolicy::_narrow (policy.in ()); RTCORBA::ProtocolList_var protocols1 = policy1->protocols (); RTCORBA::ProtocolList_var protocols2 = policy2->protocols (); ACE_ASSERT (protocols1->length () == protocols2->length ()); } { RTCORBA::ProtocolList empty_protocols; RTCORBA::ClientProtocolPolicy_var policy1 = rtorb->create_client_protocol_policy (empty_protocols); CORBA::Any policy_value; policy_value <<= empty_protocols; CORBA::Policy_var policy = orb->create_policy (RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE, policy_value); RTCORBA::ClientProtocolPolicy_var policy2 = RTCORBA::ClientProtocolPolicy::_narrow (policy.in ()); RTCORBA::ProtocolList_var protocols1 = policy1->protocols (); RTCORBA::ProtocolList_var protocols2 = policy2->protocols (); ACE_ASSERT (protocols1->length () == protocols2->length ()); } { RTCORBA::PrivateConnectionPolicy_var policy1 = rtorb->create_private_connection_policy (); CORBA::Any policy_value; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE, policy_value); RTCORBA::PrivateConnectionPolicy_var policy2 = RTCORBA::PrivateConnectionPolicy::_narrow (policy.in ()); } { RTCORBA::PriorityBands empty_priority_bands; RTCORBA::PriorityBandedConnectionPolicy_var policy1 = rtorb->create_priority_banded_connection_policy (empty_priority_bands); CORBA::Any policy_value; policy_value <<= empty_priority_bands; CORBA::Policy_var policy = orb->create_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE, policy_value); RTCORBA::PriorityBandedConnectionPolicy_var policy2 = RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy.in ()); RTCORBA::PriorityBands_var priority_bands1 = policy1->priority_bands (); RTCORBA::PriorityBands_var priority_bands2 = policy2->priority_bands (); ACE_ASSERT (priority_bands1->length () == priority_bands2->length ()); } ACE_DEBUG ((LM_DEBUG, "%s successful\n", argv[0])); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { PortableInterceptor::ORBInitializer_ptr temp_initializer = PortableInterceptor::ORBInitializer::_nil (); ACE_NEW_RETURN (temp_initializer, Server_ORBInitializer, -1); // No CORBA exceptions yet! PortableInterceptor::ORBInitializer_var orb_initializer = temp_initializer; PortableInterceptor::register_orb_initializer (orb_initializer.in ()); CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "test_orb"); // Create the test policy. const CORBA::ULong val = 40442; CORBA::Any any; any <<= val; CORBA::Policy_var p (orb->create_policy (Test::POLICY_TYPE, any)); const CORBA::PolicyType ptype = p->policy_type (); // Sanity check. if (ptype != Test::POLICY_TYPE) throw CORBA::INTERNAL (); Test::Policy_var policy (Test::Policy::_narrow (p.in ())); const CORBA::ULong pval = policy->value (); // Sanity check. if (val != pval) throw CORBA::INTERNAL (); CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, "Unable to obtain RootPOA reference.\n"), -1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); CORBA::PolicyList policies (1); policies.length (1); policies[0] = policy->copy (); PortableServer::POA_var poa = root_poa->create_POA ("Test POA", poa_manager.in (), policies); policy->destroy (); poa_manager->activate (); root_poa->destroy (1, 1); orb->destroy (); ACE_DEBUG ((LM_INFO, "\n" "PolicyFactory test succeeded.\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("PolicyFactory test:"); return -1; } return 0; }
int Task::svc (void) { int result = 0; try { CORBA::Object_var object = this->orb_->string_to_object (ior); Test_var server = Test::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Object reference <%s> is nil\n", ior), -1); } // Check that the object is configured with CLIENT_PROPAGATED // PriorityModelPolicy. CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (CORBA::is_nil (priority_policy.in ())) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Priority Model Policy not exposed!\n"), -1); RTCORBA::PriorityModel priority_model = priority_policy->priority_model (); if (priority_model != RTCORBA::CLIENT_PROPAGATED) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: priority_model != " "RTCORBA::CLIENT_PROPAGATED!\n"), -1); // Make several invocations, changing the priority of this thread // for each. object = this->orb_->resolve_initial_references ("RTCurrent"); RTCORBA::Current_var current = RTCORBA::Current::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("PriorityMappingManager"); RTCORBA::PriorityMappingManager_var mapping_manager = RTCORBA::PriorityMappingManager::_narrow (object.in ()); RTCORBA::PriorityMapping *pm = mapping_manager->mapping (); int sched_policy = this->orb_->orb_core ()->orb_params ()->ace_sched_policy (); int max_priority = ACE_Sched_Params::priority_max (sched_policy); int min_priority = ACE_Sched_Params::priority_min (sched_policy); CORBA::Short native_priority = (max_priority - min_priority) / 2; CORBA::Short desired_priority = 0; for (int i = 0; i < 3; ++i) { if (pm->to_CORBA (native_priority, desired_priority) == 0) { ACE_ERROR ((LM_ERROR, "ERROR: Cannot convert native priority %d to corba priority\n", native_priority)); result = -1; break; } current->the_priority (desired_priority); CORBA::Short priority = current->the_priority (); if (desired_priority != priority) { ACE_ERROR ((LM_ERROR, "ERROR: No exception setting the priority but mismatch between requested and returned value from Current. " "Set to %d but Current::the_priority returns %d\n", desired_priority, priority)); result = -1; } server->test_method (priority); native_priority++; } // Shut down Server ORB. server->shutdown (); } catch (const CORBA::DATA_CONVERSION& ex) { ex._tao_print_exception ( "Most likely, this is due to the in-ability " "to set the thread priority."); return -1; } catch (const CORBA::Exception & ae) { ae._tao_print_exception ( "Caught exception:"); return -1; } return result; }
void TAO_POA_RT_Policy_Validator::validate_server_protocol (TAO_Policy_Set &policies) { // Make sure we have an endpoint for at least one of the protocols // specified in the RTCORBA::ServerProtocolPolicy. This ensure we // will be able to create non-nil object references. CORBA::Policy_var protocol = policies.get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL); if (CORBA::is_nil (protocol.in ())) { // If the server protocol policy has not been specified, then // add a server policy that reflects the protocols supported by // the acceptor registries of the POA's thread pool. protocol = TAO_POA_RT_Policy_Validator::server_protocol_policy_from_thread_pool (this->thread_pool_, this->orb_core_); if (!CORBA::is_nil (protocol.in ())) { // If so, we'll use that policy. policies.set_policy (protocol.in ()); } } RTCORBA::ServerProtocolPolicy_var server_protocol_policy = RTCORBA::ServerProtocolPolicy::_narrow (protocol.in ()); TAO_ServerProtocolPolicy *server_protocol = dynamic_cast <TAO_ServerProtocolPolicy *> (server_protocol_policy.in ()); RTCORBA::ProtocolList &protocols = server_protocol->protocols_rep (); for (CORBA::ULong j = 0; j < protocols.length (); ++j) { bool found = false; CORBA::ULong const protocol_type = protocols[j].protocol_type; if (this->thread_pool_) { TAO_Thread_Lane **lanes = this->thread_pool_->lanes (); for (CORBA::ULong i = 0; i != this->thread_pool_->number_of_lanes (); ++i) { TAO_Thread_Lane_Resources &resources = lanes[i]->resources (); TAO_Acceptor_Registry &acceptor_registry = resources.acceptor_registry (); for (TAO_AcceptorSetIterator a = acceptor_registry.begin (); a != acceptor_registry.end (); ++a) { if ((*a)->tag () == protocol_type) { found = true; break; } } } } else { TAO_Thread_Lane_Resources_Manager &thread_lane_resources_manager = this->orb_core_.thread_lane_resources_manager (); TAO_Thread_Lane_Resources &resources = thread_lane_resources_manager.default_lane_resources (); TAO_Acceptor_Registry &acceptor_registry = resources.acceptor_registry (); for (TAO_AcceptorSetIterator a = acceptor_registry.begin (); a != acceptor_registry.end (); ++a) { if ((*a)->tag () == protocol_type) { found = true; break; } } } if (!found) throw PortableServer::POA::InvalidPolicy (); } }
TAO_Stub * TAO_RT_POA::key_to_stub_i (const TAO::ObjectKey &object_key, const char *type_id, CORBA::Short priority) { // Client exposed policies. CORBA::PolicyList_var client_exposed_policies = this->client_exposed_policies (priority); // Server protocol policy. CORBA::Policy_var protocol = this->policies ().get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL); RTCORBA::ServerProtocolPolicy_var server_protocol_policy = RTCORBA::ServerProtocolPolicy::_narrow (protocol.in ()); TAO_ServerProtocolPolicy *server_protocol = dynamic_cast <TAO_ServerProtocolPolicy *> (server_protocol_policy.in ()); // Filter for server protocol. TAO_Server_Protocol_Acceptor_Filter filter (server_protocol->protocols_rep ()); // If this POA is using the default thread pool or a thread pool // without lanes, create the IOR with the acceptors in the thread // pool. if (this->thread_pool_ == 0 || !this->thread_pool_->with_lanes ()) { TAO_Acceptor_Registry *acceptor_registry = 0; if (this->thread_pool_ == 0) { TAO_Thread_Lane_Resources_Manager &thread_lane_resources_manager = this->orb_core_.thread_lane_resources_manager (); TAO_Thread_Lane_Resources &resources = thread_lane_resources_manager.default_lane_resources (); acceptor_registry = &resources.acceptor_registry (); } else { TAO_Thread_Lane **lanes = this->thread_pool_->lanes (); TAO_Thread_Lane_Resources &resources = lanes[0]->resources (); acceptor_registry = &resources.acceptor_registry (); } return this->TAO_Regular_POA::create_stub_object (object_key, type_id, client_exposed_policies._retn (), &filter, *acceptor_registry); } // If this POA has the SERVER_DECLARED policy, create the IOR with // the acceptors in the only thread lane that matches the priority // of the object. if (this->cached_policies_.priority_model () == TAO::Portable_Server::Cached_Policies::SERVER_DECLARED) { TAO_Thread_Lane **lanes = this->thread_pool_->lanes (); for (CORBA::ULong i = 0; i != this->thread_pool_->number_of_lanes (); ++i) { if (lanes[i]->lane_priority () == priority) return this->TAO_Regular_POA::create_stub_object (object_key, type_id, client_exposed_policies._retn (), &filter, lanes[i]->resources ().acceptor_registry () ); } ACE_ASSERT (0); } // If this POA has the CLIENT_PROPAGATED policy, create the IOR with // the acceptors in the thread lanes that matches the bands in this // POA. If there are no bands, all the thread lanes are used. CORBA::Policy_var bands = this->policies ().get_cached_policy ( TAO_CACHED_POLICY_RT_PRIORITY_BANDED_CONNECTION ); RTCORBA::PriorityBandedConnectionPolicy_var priority_bands = RTCORBA::PriorityBandedConnectionPolicy::_narrow (bands.in ()); TAO_PriorityBandedConnectionPolicy *priority_bands_i = dynamic_cast <TAO_PriorityBandedConnectionPolicy *> (priority_bands.in ()); return this->create_stub_object (object_key, type_id, client_exposed_policies._retn (), &filter, priority_bands_i); }
void Activity::activate_schedule (void) { TASK_LIST list; int count = builder_->task_list (list); if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "Activating schedule, task count = %d\n", count)); ACE_NEW (barrier_, ACE_Barrier (count+1)); Periodic_Task* task; for (int i = 0; i < count; ++i) { task = list[i]; // resolve the object from the naming service CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup (task->job ()); CORBA::Object_var obj = this->naming_->resolve (name); Job_var job = Job::_narrow (obj.in ()); if (TAO_debug_level > 0) { // Check that the object is configured with some // PriorityModelPolicy. CORBA::Policy_var policy = job->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (CORBA::is_nil (priority_policy.in ())) ACE_DEBUG ((LM_DEBUG, "ERROR: Priority Model Policy not exposed!\n")); else { RTCORBA::PriorityModel priority_model = priority_policy->priority_model (); if (priority_model == RTCORBA::CLIENT_PROPAGATED) ACE_DEBUG ((LM_DEBUG, "%C priority_model = RTCORBA::CLIENT_PROPAGATED\n", task->job ())); else ACE_DEBUG ((LM_DEBUG, "%C priority_model = RTCORBA::SERVER_DECLARED\n", task->job ())); } } /* if (TAO_debug_level > 0) */ task->job (job.in ()); task->activate_task (this->barrier_, this->priority_mapping_); active_task_count_++; ACE_DEBUG ((LM_DEBUG, "Job %C scheduled\n", task->job ())); } ACE_DEBUG ((LM_DEBUG, "(%P,%t) Waiting for tasks to synch...\n")); barrier_->wait (); ACE_DEBUG ((LM_DEBUG, "(%P,%t) Tasks have synched...\n")); }
int main (int argc, char *argv[]) { try { orb = CORBA::ORB_init (argc, argv, ""); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; poa_manager->activate(); Hello *hello_impl; ACE_NEW_RETURN (hello_impl, Hello (shutdown_handler), 1); PortableServer::ServantBase_var owner_transfer(hello_impl); Test::Hello_var hello = hello_impl->_this (); ACE_DEBUG ((LM_DEBUG, "getting proxy reference\n")); CORBA::Object_var obj = orb->string_to_object (lorica_ior); #if 0 Security::QOP qop = Security::SecQOPNoProtection; CORBA::Any no_protection; no_protection <<= qop; // Create the Security::QOPPolicy. CORBA::Policy_var policy = orb->create_policy (Security::SecQOPPolicy, no_protection); CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = CORBA::Policy::_duplicate (policy.in ()); // Create an object reference that uses plain IIOP (i.e. no // protection). obj = obj->_set_policy_overrides (policy_list, CORBA::SET_OVERRIDE); #endif ACE_DEBUG ((LM_DEBUG, "narrowing proxy reference\n")); mapper = Lorica::ReferenceMapper::_narrow(obj.in()); if (CORBA::is_nil(mapper.in())) ACE_ERROR_RETURN ((LM_ERROR, "Cannot get reference to Lorica " "reference mapper\n"),1); #if 1 obj = register_with_proxy (hello.in()); #else obj = mapper->as_server (hello.in(),"Hello", Lorica::ServerAgent::_nil()); #endif ACE_DEBUG ((LM_DEBUG,"register_with_proxy() returned\n")); if (CORBA::is_nil (obj.in())) ACE_ERROR_RETURN ((LM_ERROR, "Lorica reference mapper returned a nil " "mapped reference.\n"),1); mapped_hello = Test::Hello::_narrow(obj.in()); if (CORBA::is_nil(mapped_hello.in())) ACE_ERROR_RETURN ((LM_ERROR, "Lorica reference mapper returned an " "incorrectly typed reference\n"),1); CORBA::String_var orig_ior = orb->object_to_string (hello.in ()); CORBA::String_var mapped_ior = orb->object_to_string (mapped_hello.in()); if (ACE_OS::strcmp (orig_ior.in(), mapped_ior.in()) == 0) ACE_ERROR_RETURN ((LM_ERROR, "Lorica reference mapper returned " "the original reference unmapped.\n"),1); ACE_DEBUG ((LM_DEBUG,"writing original IOR to file %s\n",orig_file)); ACE_DEBUG ((LM_DEBUG,"writing mapped IOR to file %s\n",mapped_file)); ACE_DEBUG ((LM_DEBUG,"Size of orig IOR = %d, size of mapped = %d\n", ACE_OS::strlen(orig_ior.in()), ACE_OS::strlen(mapped_ior.in()))); FILE *output_file= ACE_OS::fopen (mapped_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s\n", mapped_file), 1); ACE_OS::fprintf (output_file, "%s", mapped_ior.in()); ACE_OS::fclose (output_file); output_file= ACE_OS::fopen (orig_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s\n", orig_file), 1); ACE_OS::fprintf (output_file, "%s", orig_ior.in()); ACE_OS::fclose (output_file); if (linger) orb->run(); else shutdown_handler(); // No need to run the ORB the test only requires modifying an IOR orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int Task::svc (void) { try { // Priority Mapping Manager. CORBA::Object_var object = this->orb_->resolve_initial_references ("PriorityMappingManager"); RTCORBA::PriorityMappingManager_var mapping_manager = RTCORBA::PriorityMappingManager::_narrow (object.in ()); if (check_for_nil (mapping_manager.in (), "Mapping Manager") == -1) return -1; RTCORBA::PriorityMapping *pm = mapping_manager->mapping (); // RTCurrent. object = this->orb_->resolve_initial_references ("RTCurrent"); RTCORBA::Current_var current = RTCORBA::Current::_narrow (object.in ()); if (check_for_nil (current.in (), "RTCurrent") == -1) return -1; // Obtain Test object reference. object = this->orb_->string_to_object (ior); Test_var server = Test::_narrow (object.in ()); if (check_for_nil (server.in (), "Test object") == -1) return -1; // Check that test object is configured with CLIENT_PROPAGATED // PriorityModelPolicy. CORBA::Policy_var policy = server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE); RTCORBA::PriorityModelPolicy_var priority_policy = RTCORBA::PriorityModelPolicy::_narrow (policy.in ()); if (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1) return -1; RTCORBA::PriorityModel priority_model = priority_policy->priority_model (); if (priority_model != RTCORBA::CLIENT_PROPAGATED) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: priority_model != " "RTCORBA::CLIENT_PROPAGATED!\n"), -1); // Spawn two worker threads. ACE_Barrier thread_barrier (2); int flags = THR_NEW_LWP | THR_JOINABLE | this->orb_->orb_core ()->orb_params ()->thread_creation_flags (); // Worker 1. Worker_Thread worker1 (this->orb_.in (), server.in (), protocol1, &thread_barrier); CORBA::Short native_priority1 = 0; if (pm->to_native (priority1, native_priority1) == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot convert corba priority %d to native priority\n", priority1), -1); if (worker1.activate (flags, 1, 0, native_priority1) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot activate first client worker threads\n"), -1); // Worker 2. Worker_Thread worker2 (this->orb_.in (), server.in (), protocol2, &thread_barrier); CORBA::Short native_priority2 = 0; if (pm->to_native (priority2, native_priority2) == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot convert corba priority %d to native priority\n", priority2), -1); if (worker2.activate (flags, 1, 0, native_priority2) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot activate second client worker threads\n"), -1); // Wait for worker threads to finish. ACE_Thread_Manager::instance ()->wait (); // Testing over. Shut down the server. ACE_DEBUG ((LM_DEBUG, "Client threads finished\n")); current->the_priority (priority1); server->shutdown (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "Unexpected exception in MT_Client_Protocol_Priority test client:"); return -1; } return 0; }