int TAO_AV_Callback::handle_stop (void) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,"TAO_AV_Callback::handle_stop\n")); return -1; }
int TAO_AV_Core::init_forward_flows (TAO_Base_StreamEndPoint *endpoint, TAO_AV_FlowSpecSet &flow_spec_set, TAO_AV_Core::EndPoint direction, AVStreams::flowSpec &flow_spec) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_AV_Core::init_forward_flows\n")); TAO_AV_FlowSpecSet address_flow_set; TAO_AV_FlowSpecSet flow_set; TAO_AV_FlowSpecSetItor end = flow_spec_set.end (); for (TAO_AV_FlowSpecSetItor start = flow_spec_set.begin (); start != end; ++start) { TAO_FlowSpec_Entry *entry = (*start); switch (direction) { case TAO_AV_Core::TAO_AV_ENDPOINT_B: { switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_IN: { entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER); break; } case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT: { entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER); break; } } break; } case TAO_AV_Core::TAO_AV_ENDPOINT_A: { switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_IN: entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER); break; case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT: entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER); break; } break; } default: break; } ACE_Addr *address = entry->address (); if (address != 0) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "address given for flow %s\n", entry->flowname ())); address_flow_set.insert (entry); } else flow_set.insert (entry); } //End of For Loop int result = -1; switch (direction) { case TAO_AV_Core::TAO_AV_ENDPOINT_A: if (address_flow_set.size () > 0) { result = this->acceptor_registry_->open (endpoint, this, address_flow_set); if (result < 0) ORBSVCS_ERROR_RETURN ((LM_ERROR, "TAO_AV_Core::init_forward_flows::acceptor_registry::open failed\n"), -1); TAO_AV_FlowSpecSetItor end = address_flow_set.end (); for (TAO_AV_FlowSpecSetItor start = address_flow_set.begin (); start != end; ++start) { TAO_FlowSpec_Entry *entry = (*start); switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_IN: { if (entry->handler () != 0) { //Yamuna:PLEASE CHECK THIS LATER #if defined ACE_HAS_RAPI || defined (ACE_HAS_WINSOCK2_GQOS) // For IN flows on the A side we should remove the handlers from the reactor. ACE_Event_Handler *event_handler = entry->handler ()->event_handler (); if (event_handler->reactor () != 0) { result = event_handler->reactor ()->remove_handler (event_handler, ACE_Event_Handler::READ_MASK); if (result < 0) if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_AV_Core::init_forward_flows: remove_handler failed\n")); } #endif //ACE_HAS_RAPI || ACE_HAS_WINSOCK2_GQOS } } default: break; } // Now if the address_set has been changed due to the addition of a control entry we should // add that to the flow_spec_set also. if (flow_spec_set.find (entry) < 0) { // entry doesn't exist so add it. flow_spec_set.insert (entry); // size_t len = flow_spec.length (); // flow_spec.length (len+1); // flow_spec [len] = entry->entry_to_string (); } } } break; case TAO_AV_Core::TAO_AV_ENDPOINT_B: { if (address_flow_set.size () > 0) { ORBSVCS_DEBUG ((LM_DEBUG, "(%N,%l) This connector registry is called\n")); result = this->connector_registry_->open (endpoint, this, address_flow_set); if (result == -1) ORBSVCS_ERROR_RETURN ((LM_ERROR,"TAO_AV_Core::init_Forward_flows: connector_registry open failed\n"),-1); TAO_AV_FlowSpecSetItor end = address_flow_set.end (); for (TAO_AV_FlowSpecSetItor start = address_flow_set.begin (); start != end; ++start) { TAO_FlowSpec_Entry *entry = (*start); switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT: { if (entry->handler () != 0) { // @@Naga: This wont be called in the case of Full Profile. // For IN flows on the A side we should remove the handlers from the reactor. ACE_Event_Handler *event_handler = entry->handler ()->event_handler (); result = event_handler->reactor ()->remove_handler (event_handler, ACE_Event_Handler::READ_MASK); if (result < 0) if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_AV_Core::init_forward_flows: remove_handler failed\n")); } } default: break; } // Now if the address_set has been changed due to the addition of a control entry we should // add that to the flow_spec_set also. if (flow_spec_set.find (entry) < 0) { // entry doesn't exist so add it. flow_spec_set.insert (entry); } } } if (flow_set.size () > 0) { // If any of the flow spec entries have a valid peer address, // we need to set it as the forwarding address. According to // Yamuna Krishnamurthy, this "happens when no address is // specified for the A endpoint." TAO_AV_FlowSpecSetItor end = flow_set.end (); TAO_AV_FlowSpecSetItor start = flow_set.begin (); for (; start != end; ++start) { TAO_FlowSpec_Entry *entry = *start; if (entry->get_peer_addr () != 0) { entry->address (entry->get_peer_addr (), false); } } result = this->acceptor_registry_->open (endpoint, this, flow_set); if (result == -1) ORBSVCS_ERROR_RETURN ((LM_ERROR,"TAO_AV_Core::init_Forward_flows: Acceptor_registry open failed\n"),-1); end = address_flow_set.end (); start = address_flow_set.begin (); for (; start != end; ++start) { TAO_FlowSpec_Entry *entry = (*start); switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT: { if (entry->handler () != 0) { // For IN flows on the A side we should remove the handlers from the reactor. ACE_Event_Handler *event_handler = entry->handler ()->event_handler (); result = event_handler->reactor ()->remove_handler (event_handler, ACE_Event_Handler::READ_MASK); if (result < 0) if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_AV_Core::init_forward_flows: remove_handler failed\n")); } } default: break; } // Now if the address_set has been changed due to the addition of a control entry we should // add that to the flow_spec_set also. if (flow_spec_set.find (entry) < 0) { // entry doesn't exist so add it. flow_spec_set.insert (entry); } } } AVStreams::flowSpec new_flowspec (static_cast<CORBA::ULong> (flow_spec_set.size ())); int i=0; TAO_AV_FlowSpecSetItor connect_end = address_flow_set.end (); TAO_AV_FlowSpecSetItor connect = address_flow_set.begin (); for (;connect != connect_end; ++connect) { ACE_Addr *local_addr; ACE_Addr *local_control_addr; local_addr = (*connect)->get_local_addr (); local_control_addr = (*connect)->get_local_control_addr (); if (local_addr != 0) { TAO_Reverse_FlowSpec_Entry entry ((*connect)->flowname (), (*connect)->direction_str (), (*connect)->format (), (*connect)->flow_protocol_str (), (*connect)->carrier_protocol_str (), local_addr, local_control_addr); /* ACE_Addr *addr; if ((addr = (*connect)->get_peer_addr ()) != 0) { entry.set_peer_addr (addr); }; */ int len = new_flowspec.length (); if (i == len) new_flowspec.length (len+1); new_flowspec [i++] = entry.entry_to_string (); if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "reverse Flow Spec Is %s\n", entry.entry_to_string ())); } } connect_end = flow_set.end (); for (connect = flow_set.begin (); connect != connect_end; ++connect) { ACE_Addr *local_addr; ACE_Addr *local_control_addr; local_addr = (*connect)->get_local_addr (); local_control_addr = (*connect)->get_local_control_addr (); if (local_addr != 0) { TAO_Reverse_FlowSpec_Entry entry ((*connect)->flowname (), (*connect)->direction_str (), (*connect)->format (), (*connect)->flow_protocol_str (), (*connect)->carrier_protocol_str (), local_addr, local_control_addr); int len = new_flowspec.length (); if (i == len) new_flowspec.length (len+1); new_flowspec [i++] = entry.entry_to_string (); } } // Change the reverse flow spec to be sent. // int index = flow_spec.length () + 1; int index = new_flowspec.length (); flow_spec.length (index); for (i = 0; i < index; i++) { flow_spec [i] = new_flowspec [i]; } } break; default: break; } return 0; }
void AsyncListManager::final_state (void) { if (ImR_Locator_i::debug() > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) AsyncListManager(%@)::final_state, ") ACE_TEXT ("waiters count = %d, has pinger? %d\n"), this, this->waiters_, (this->pinger_ != 0))); } if (this->pinger_ != 0 && this->waiters_ > 0) { return; } bool excepted = false; CORBA::ULong len = this->server_list_.length (); ImplementationRepository::ServerInformationList alt_list (this->how_many_); ImplementationRepository::ServerInformationList *sil = &this->server_list_; if (this->first_ > 0 || this->how_many_ < len) { alt_list.length (this->how_many_); for (CORBA::ULong i = 0; i < this->how_many_; i++) { alt_list[i] = this->server_list_[i + this->first_]; } sil = &alt_list; } if (!CORBA::is_nil (this->primary_.in ())) { ImplementationRepository::ServerInformationIterator_var server_iterator; if (sil != &this->server_list_) { excepted = !this->make_iterator (server_iterator.out(), this->how_many_); } else { server_iterator = ImplementationRepository::ServerInformationIterator::_nil (); } if (!excepted) { try { this->primary_->list (*sil, server_iterator.in ()); } catch (CORBA::Exception &ex) { ex._tao_print_exception ("AsyncListManager:final state sending list\n"); ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate()); this->primary_->list_excep (&h); } } this->primary_ = ImplementationRepository::AMH_AdministrationResponseHandler::_nil (); } else if (!CORBA::is_nil (this->secondary_.in())) { CORBA::Boolean done = this->first_ + sil->length() == len; try { this->secondary_->next_n (done, *sil); } catch (CORBA::Exception &ex) { ex._tao_print_exception ("AsyncListManager:final state sending secondary list\n"); ImplementationRepository::AMH_ServerInformationIteratorExceptionHolder h (ex._tao_duplicate()); this->secondary_->next_n_excep (&h); } this->secondary_ = ImplementationRepository::AMH_ServerInformationIteratorResponseHandler::_nil (); } }
CORBA::ParDescriptionSeq * TAO_OperationDef_i::params_i (void) { CORBA::ULong i = 0; ACE_Configuration_Section_Key params_key; int status = this->repo_->config ()->open_section (this->section_key_, "params", 0, params_key); ACE_Unbounded_Queue<ACE_Configuration_Section_Key> key_queue; // This section may not have been created. if (status == 0) { u_int count = 0; this->repo_->config ()->get_integer_value (params_key, "count", count); for (i = 0; i < count; ++i) { ACE_Configuration_Section_Key param_key; char *stringified = TAO_IFR_Service_Utils::int_to_string (i); status = this->repo_->config ()->open_section (params_key, stringified, 0, param_key); if (status == 0) { key_queue.enqueue_tail (param_key); } } } CORBA::ULong size = static_cast<CORBA::ULong> (key_queue.size ()); CORBA::ParDescriptionSeq *pd_seq = 0; ACE_NEW_THROW_EX (pd_seq, CORBA::ParDescriptionSeq (size), CORBA::NO_MEMORY ()); pd_seq->length (size); if (size == 0) { return pd_seq; } CORBA::ParDescriptionSeq_var retval = pd_seq; for (i = 0; i < size; ++i) { ACE_Configuration_Section_Key key; key_queue.dequeue_head (key); ACE_TString name; this->repo_->config ()->get_string_value (key, "name", name); retval[i].name = name.c_str (); u_int mode = 0; this->repo_->config ()->get_integer_value (key, "mode", mode); retval[i].mode = static_cast<CORBA::ParameterMode> (mode); ACE_TString type_path; this->repo_->config ()->get_string_value (key, "type_path", type_path); TAO_IDLType_i *impl = TAO_IFR_Service_Utils::path_to_idltype (type_path, this->repo_); // We have an undefined interface if (impl == 0) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("Encountered undefined parameter type " "for variable: %s\n"), name.c_str ())); throw CORBA::INTF_REPOS (); } retval[i].type = impl->type_i (); CORBA::Object_var obj = TAO_IFR_Service_Utils::path_to_ir_object (type_path, this->repo_); retval[i].type_def = CORBA::IDLType::_narrow (obj.in ()); } return retval._retn (); }
int Task_Entry::conjunctive_merge (Dependency_Type dt, ACE_Unbounded_Set <Dispatch_Entry *> &dispatch_entries, ACE_CString &unresolved_locals, ACE_CString &unresolved_remotes) { int result = 0; char string_buffer [BUFSIZ]; // Iterate over the dependencies, and determine the total frame // size. u_long frame_size = 1; ACE_Unbounded_Set_Iterator <Task_Entry_Link *> dep_iter (callers_); for (dep_iter.first (); dep_iter.done () == 0; dep_iter.advance ()) { Task_Entry_Link **link; if (dep_iter.next (link) == 0 || link == 0 || *link == 0) return -1; // The link matches the dependency type given. if ((*link)->dependency_type () == dt) { // Check for and warn about unresolved remote dependencies // in the ONE_WAY call graph. if ((*link)->dependency_type () == RtecBase::ONE_WAY_CALL && (*link)->caller ().has_unresolved_remote_dependencies () && ! this->has_unresolved_remote_dependencies ()) { // Propagate the unresolved remote dependency flag, and // issue a debug scheduler warning. this->has_unresolved_remote_dependencies (1); ORBSVCS_DEBUG ((LM_DEBUG, "Warning: an operation identified by " "\"%s\" has unresolved remote dependencies.\n", (const char*) this->rt_info ()->entry_point)); // Record entry point in list of unresolved remote // dependencies ACE_OS::sprintf (string_buffer, "// %s\n", (const char*) this->rt_info ()->entry_point); unresolved_remotes += ACE_CString (string_buffer); } // Check for and warn about unresolved local dependencies in // the ONE_WAY call graph. if ((*link)->dependency_type () == RtecBase::ONE_WAY_CALL && (*link)->caller ().has_unresolved_local_dependencies () && ! this->has_unresolved_local_dependencies ()) { // Propagate the unresolved local dependency flag, and // issue a debug scheduler warning. this->has_unresolved_local_dependencies (1); ORBSVCS_DEBUG ((LM_DEBUG, "Warning: an operation identified by " "\"%s\" has unresolved local dependencies.\n", (const char*) this->rt_info ()->entry_point)); // Record entry point in list of unresolved local dependencies ACE_OS::sprintf (string_buffer, "// %s\n", (const char*) this->rt_info ()->entry_point); unresolved_locals += ACE_CString (string_buffer); } frame_size = ACE::minimum_frame_size (frame_size, (*link)->caller ().effective_period_); } } // Reframe dispatches in the set to the new frame size (expands the // set's effective period to be the new enclosing frame). if (reframe (dispatch_entries, *this, dispatches_, effective_period_, frame_size) < 0) return -1; // A container and iterator for virtual dispatch sets over which the // conjunction will operate ACE_Ordered_MultiSet <Dispatch_Proxy_Iterator *> conj_set; ACE_Ordered_MultiSet_Iterator <Dispatch_Proxy_Iterator *> conj_set_iter (conj_set); // Iterate over the dependencies, and for each of the given call // type, create a Dispatch_Proxy_Iterator for the caller's dispatch // set, using the caller's period, the total frame size, and the // number of calls: if any of the sets is empty, just return 0; for (dep_iter.first (); dep_iter.done () == 0; dep_iter.advance ()) { Task_Entry_Link **link; if (dep_iter.next (link) == 0 || link == 0 || *link == 0) return -1; // The link matches the dependency type given. if ((*link)->dependency_type () == dt) { Dispatch_Proxy_Iterator *proxy_ptr; ACE_NEW_RETURN (proxy_ptr, Dispatch_Proxy_Iterator ((*link)->caller ().dispatches_, (*link)->caller ().effective_period_, frame_size, (*link)->number_of_calls ()), -1); // If there are no entries in the virtual set, we're done. if (proxy_ptr->done ()) return 0; else if (conj_set.insert (proxy_ptr, conj_set_iter) < 0) return -1; } } // loop, adding conjunctive dispatches, until one of the conjunctive // dispatch sources runs out of entries over the total frame conj_set_iter.first (); int more_dispatches = (conj_set_iter.done ()) ? 0 : 1; while (more_dispatches) { Time arrival = 0; Time deadline = 0; Preemption_Priority priority = 0; OS_Priority OS_priority = 0; for (conj_set_iter.first (); conj_set_iter.done () == 0; conj_set_iter.advance ()) { // initialize to earliest arrival and deadline, and highest priority arrival = 0; deadline = 0; priority = 0; OS_priority = 0; // Policy: conjunctively dispatched operations get the // latest deadline of any of the dispatches in the // conjunction at the time they were dispatched - when and // if it is useful to change any of the merge policies, this // should be one of the decisions factored out into the // conjunctive merge strategy class. // Policy: conjunctively dispatched operations get the // lowest priority of any of the dispatches in the // conjunction at the time they were dispatched - when and // if it is useful to change any of the merge policies, this // should be one of the decisions factored out into the // conjunctive merge strategy class. // Obtain a pointer to the current dispatch proxy iterator. Dispatch_Proxy_Iterator **proxy_iter; if (conj_set_iter.next (proxy_iter) == 0 || proxy_iter == 0 || *proxy_iter == 0) return -1; // Use latest arrival, latest deadline, lowest priority (0 is highest). if (arrival <= (*proxy_iter)->arrival ()) arrival = (*proxy_iter)->arrival (); if (deadline <= (*proxy_iter)->deadline ()) deadline = (*proxy_iter)->deadline (); if (priority <= (*proxy_iter)->priority ()) { priority = (*proxy_iter)->priority (); OS_priority = (*proxy_iter)->OS_priority (); } (*proxy_iter)->advance (); if ((*proxy_iter)->done ()) more_dispatches = 0; } Dispatch_Entry *entry_ptr; ACE_NEW_RETURN (entry_ptr, Dispatch_Entry (arrival, deadline, priority, OS_priority, *this), -1); // If even one new dispatch was inserted, result is "something // happened". result = 1; // Add the new dispatch entry to the set of all dispatches, and // a link to it to the dispatch links for this task entry. if (dispatch_entries.insert (entry_ptr) < 0) return -1; // Use iterator for efficient insertion into the dispatch set. ACE_Ordered_MultiSet_Iterator <Dispatch_Entry_Link> insert_iter (dispatches_); if (dispatches_.insert (Dispatch_Entry_Link (*entry_ptr), insert_iter) < 0) return -1; // TBD - Clients are not assigned priority, but rather obtain it // from their call dependencies. We could complain here if // there is a priority specified that doesn't match (or is lower // QoS?) } return result; }
void TAO_ECG_CDR_Message_Sender::send_fragment (const ACE_INET_Addr &addr, CORBA::ULong request_id, CORBA::ULong request_size, CORBA::ULong fragment_size, CORBA::ULong fragment_offset, CORBA::ULong fragment_id, CORBA::ULong fragment_count, iovec iov[], int iovcnt) { CORBA::ULong header[TAO_ECG_CDR_Message_Sender::ECG_HEADER_SIZE / sizeof(CORBA::ULong) + ACE_CDR::MAX_ALIGNMENT]; char* buf = reinterpret_cast<char*> (header); TAO_OutputCDR cdr (buf, sizeof(header)); cdr.write_boolean (TAO_ENCAP_BYTE_ORDER); // Insert some known values in the padding bytes, so we can smoke // test the message on the receiving end. cdr.write_octet ('A'); cdr.write_octet ('B'); cdr.write_octet ('C'); cdr.write_ulong (request_id); cdr.write_ulong (request_size); cdr.write_ulong (fragment_size); cdr.write_ulong (fragment_offset); cdr.write_ulong (fragment_id); cdr.write_ulong (fragment_count); CORBA::Octet padding[4]; // MRH if (checksum_) { // Compute CRC iov[0].iov_base = cdr.begin ()->rd_ptr (); iov[0].iov_len = cdr.begin ()->length (); unsigned int crc = 0; unsigned char *crc_parts = (unsigned char *)(&crc); if (iovcnt > 1) { crc = ACE::crc32 (iov, iovcnt); crc = ACE_HTONL (crc); } for (int cnt=0; cnt<4; ++cnt) { padding[cnt] = crc_parts[cnt]; } } else { for (int cnt=0; cnt<4; ++cnt) { padding[cnt] = 0; } } //End MRH cdr.write_octet_array (padding, 4); iov[0].iov_base = cdr.begin ()->rd_ptr (); iov[0].iov_len = cdr.begin ()->length (); ssize_t n = this->dgram ().send (iov, iovcnt, addr); size_t expected_n = 0; for (int i = 0; i < iovcnt; ++i) expected_n += iov[i].iov_len; if (n > 0 && size_t(n) != expected_n) { ORBSVCS_ERROR ((LM_ERROR, ("Sent only %d out of %d bytes " "for mcast fragment.\n"), n, expected_n)); } if (n == -1) { if (errno == EWOULDBLOCK) { ORBSVCS_ERROR ((LM_ERROR, "Send of mcast fragment failed (%m).\n")); // @@ TODO Use a Event Channel specific exception throw CORBA::COMM_FAILURE (); } else { ORBSVCS_DEBUG ((LM_WARNING, "Send of mcast fragment blocked (%m).\n")); } } else if (n == 0) { ORBSVCS_DEBUG ((LM_WARNING, "EOF on send of mcast fragment (%m).\n")); } }
int TAO::PG_Object_Group::set_primary_member ( TAO_IOP::TAO_IOR_Property * prop, const PortableGroup::Location & the_location) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, 0); int result = 1; MemberInfo * info = 0; if (this->members_.find (the_location, info) == 0) { int cleared = 0; this->primary_location_ = the_location; for (MemberMap_Iterator it = this->members_.begin (); !cleared && it != this->members_.end (); ++it) { cleared = (*it).int_id_->is_primary_; (*it).int_id_->is_primary_ = 0; } info->is_primary_ = 1; int set_ok = this->manipulator_.set_primary (prop, this->reference_.in (), info->member_.in ()); if (!set_ok) { if (TAO_debug_level > 3) { ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("%T %n (%P|%t) - ") ACE_TEXT ("Can't set primary in IOGR .\n") )); } //@@: ACE_THROW (FT::PrimaryNotSet()); result = 0; } if (result && this->increment_version ()) { this->distribute_iogr (); } else { if (TAO_debug_level > 3) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("TAO-PG (%P|%t) - set_primary_location ") ACE_TEXT("throwing PrimaryNotSet because increment") ACE_TEXT("version failed.\n") )); } //@@: ACE_THROW (FT::PrimaryNotSet()); result = 0; } } else { if (TAO_debug_level > 3) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO-PG (%P|%t) - set_primary_location ") ACE_TEXT ("throwing MemberNotFound.\n"))); } throw PortableGroup::MemberNotFound(); } return result; }
int TAO_Naming_Server::init_new_naming (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, const ACE_TCHAR *persistence_location, void *base_addr, size_t context_size, int enable_multicast, int use_storable_context, int round_trip_timeout, int use_round_trip_timeout) { try { #if defined (CORBA_E_MICRO) ACE_UNUSED_ARG (persistence_location); ACE_UNUSED_ARG (base_addr); ACE_UNUSED_ARG (use_storable_context); #else if (use_storable_context) { // In lieu of a fully implemented service configurator version // of this Reader and Writer, let's just take something off the // command line for now. TAO::Storable_Factory* pf = 0; ACE_CString directory (ACE_TEXT_ALWAYS_CHAR (persistence_location)); ACE_NEW_RETURN (pf, TAO::Storable_FlatFileFactory (directory), -1); auto_ptr<TAO::Storable_Factory> persFactory(pf); // Use an auto_ptr to ensure that we clean up the factory in the case // of a failure in creating and registering the Activator. TAO_Storable_Naming_Context_Factory* cf = this->storable_naming_context_factory (context_size); // Make sure we got a factory if (cf == 0) return -1; auto_ptr<TAO_Storable_Naming_Context_Factory> contextFactory (cf); // This instance will either get deleted after recreate all or, // in the case of a servant activator's use, on destruction of the // activator. // Was a location specified? if (persistence_location == 0) { // No, assign the default location "NameService" persistence_location = ACE_TEXT ("NameService"); } // Now make sure this directory exists if (ACE_OS::access (persistence_location, W_OK|X_OK)) { ORBSVCS_ERROR_RETURN ((LM_ERROR, "Invalid persistence directory\n"), -1); } #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) if (this->use_servant_activator_) { ACE_NEW_THROW_EX (this->servant_activator_, TAO_Storable_Naming_Context_Activator (orb, persFactory.get(), contextFactory.get (), persistence_location), CORBA::NO_MEMORY ()); this->ns_poa_->set_servant_manager(this->servant_activator_); } #endif /* TAO_HAS_MINIMUM_POA */ try { // The following might throw an exception. this->naming_context_ = TAO_Storable_Naming_Context::recreate_all (orb, poa, TAO_ROOT_NAMING_CONTEXT, context_size, 0, contextFactory.get (), persFactory.get (), use_redundancy_); } catch (const CORBA::Exception& ex) { // The activator already took over the factories so we need to release the auto_ptr if (this->use_servant_activator_) { // The context factory is now owned by the activator // so we should release it contextFactory.release (); // If using a servant activator, the activator now owns the // factory, so we should release it persFactory.release (); } // Print out the exception and return failure ex._tao_print_exception ( "TAO_Naming_Server::init_new_naming"); return -1; } // Kind of a duplicate of the above here, but we must also release the // factory autoptrs in the good case as well. if (this->use_servant_activator_) { // The context factory is now owned by the activator // so we should release it contextFactory.release (); // If using a servant activator, the activator now owns the // factory, so we should release it persFactory.release (); } } else if (persistence_location != 0) // // Initialize Persistent Naming Service. // { // Create Naming Context Implementation Factory to be used for the creation of // naming contexts by the TAO_Persistent_Context_Index TAO_Persistent_Naming_Context_Factory *naming_context_factory = this->persistent_naming_context_factory (); // Make sure we got a factory. if (naming_context_factory == 0) return -1; // Allocate and initialize Persistent Context Index. ACE_NEW_RETURN (this->context_index_, TAO_Persistent_Context_Index (orb, poa, naming_context_factory), -1); if (this->context_index_->open (persistence_location, base_addr) == -1 || this->context_index_->init (context_size) == -1) { if (TAO_debug_level >0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_Naming_Server: context_index initialization failed\n")); return -1; } // Set the root Naming Context reference. this->naming_context_ = this->context_index_->root_context (); } else #endif /* CORBA_E_MICRO */ { // // Initialize Transient Naming Service. // this->naming_context_ = TAO_Transient_Naming_Context::make_new_context (poa, TAO_ROOT_NAMING_CONTEXT, context_size); } #if !defined (CORBA_E_MICRO) // Register with the ORB's resolve_initial_references() // mechanism. Primarily useful for dynamically loaded Name // Services. orb->register_initial_reference ("NameService", this->naming_context_.in ()); #endif /* CORBA_E_MICRO */ // Set the ior of the root Naming Context. this->naming_service_ior_= orb->object_to_string (this->naming_context_.in ()); CORBA::Object_var table_object = orb->resolve_initial_references ("IORTable"); IORTable::Table_var adapter = IORTable::Table::_narrow (table_object.in ()); if (CORBA::is_nil (adapter.in ())) { ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n")); } else { CORBA::String_var ior = orb->object_to_string (this->naming_context_.in ()); adapter->bind ("NameService", ior.in ()); } #if defined (ACE_HAS_IP_MULTICAST) if (enable_multicast) { // @@ Marina: is there anyway to implement this stuff // without using ORB_Core_instance()? For example can you // pass the ORB as an argument? // // Install ior multicast handler. // // Get reactor instance from TAO. ACE_Reactor *reactor = orb->orb_core()->reactor (); // See if the -ORBMulticastDiscoveryEndpoint option was specified. ACE_CString mde (orb->orb_core ()->orb_params ()->mcast_discovery_endpoint ()); // First, see if the user has given us a multicast port number // on the command-line; u_short port = orb->orb_core ()->orb_params ()->service_port (TAO::MCAST_NAMESERVICE); if (port == 0) { // Check environment var. for multicast port. const char *port_number = ACE_OS::getenv ("NameServicePort"); if (port_number != 0) port = static_cast<u_short> (ACE_OS::atoi (port_number)); } // Port wasn't specified on the command-line or in environment - // use the default. if (port == 0) port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT; // Instantiate a handler which will handle client requests for // the root Naming Context ior, received on the multicast port. ACE_NEW_RETURN (this->ior_multicast_, TAO_IOR_Multicast (), -1); if (mde.length () != 0) { if (this->ior_multicast_->init (this->naming_service_ior_.in (), mde.c_str (), TAO_SERVICEID_NAMESERVICE) == -1) return -1; } else { if (this->ior_multicast_->init (this->naming_service_ior_.in (), port, #if defined (ACE_HAS_IPV6) ACE_DEFAULT_MULTICASTV6_ADDR, #else ACE_DEFAULT_MULTICAST_ADDR, #endif /* ACE_HAS_IPV6 */ TAO_SERVICEID_NAMESERVICE) == -1) return -1; } // Register event handler for the ior multicast. if (reactor->register_handler (this->ior_multicast_, ACE_Event_Handler::READ_MASK) == -1) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_Naming_Server: cannot register Event handler\n")); return -1; } if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_Naming_Server: The multicast server setup is done.\n")); } #else ACE_UNUSED_ARG (enable_multicast); #endif /* ACE_HAS_IP_MULTICAST */ #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 if (use_round_trip_timeout == 1) { TimeBase::TimeT roundTripTimeoutVal = round_trip_timeout; CORBA::Any anyObjectVal; anyObjectVal <<= roundTripTimeoutVal; CORBA::PolicyList polList (1); polList.length (1); polList[0] = orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, anyObjectVal); // set a timeout on the orb // CORBA::Object_var orbPolicyManagerObj = orb->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var orbPolicyManager = CORBA::PolicyManager::_narrow (orbPolicyManagerObj.in ()); orbPolicyManager->set_policy_overrides (polList, CORBA::SET_OVERRIDE); polList[0]->destroy (); polList[0] = CORBA::Policy::_nil (); } #else ACE_UNUSED_ARG (use_round_trip_timeout); ACE_UNUSED_ARG (round_trip_timeout); #endif /* TAO_HAS_CORBA_MESSAGING */ } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_Naming_Server::init_new_naming"); return -1; } return 0; }
bool LiveEntry::validate_ping (bool &want_reping, ACE_Time_Value& next) { if (this->liveliness_ == LS_PING_AWAY || this->liveliness_ == LS_DEAD || this->listeners_.size () == 0) { if (ImR_Locator_i::debug () > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, status ") ACE_TEXT ("= %s, listeners = %d server %C\n"), status_name (this->liveliness_), this->listeners_.size (), this->server_.c_str())); } return false; } ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr()); ACE_Time_Value diff = this->next_check_ - now; long msec = diff.msec(); if (msec > 0) { if (!want_reping || this->next_check_ < next) { want_reping = true; next = this->next_check_; } if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, ") ACE_TEXT ("status = %s, listeners = %d, ") ACE_TEXT ("diff = %d,%d, msec = %d ") ACE_TEXT ("server %C\n"), status_name (this->liveliness_), this->listeners_.size (), diff.sec(), diff.usec(), msec, this->server_.c_str())); } return false; } switch (this->liveliness_) { case LS_UNKNOWN: break; case LS_ALIVE: case LS_TIMEDOUT: { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, false); this->next_check_ = now + owner_->ping_interval(); } break; case LS_TRANSIENT: case LS_LAST_TRANSIENT: { int ms = this->next_reping (); if (ms != -1) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, false); if (this->liveliness_ == LS_LAST_TRANSIENT) { this->liveliness_ = LS_TRANSIENT; } ACE_Time_Value next (ms / 1000, (ms % 1000) * 1000); this->next_check_ = now + next; if (ImR_Locator_i::debug () > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, ") ACE_TEXT ("transient, reping in %d ms, ") ACE_TEXT ("server %C\n"), ms, this->server_.c_str())); } } else { if (this->liveliness_ == LS_TRANSIENT) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, mon, this->lock_, false); this->liveliness_ = LS_LAST_TRANSIENT; } if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveEntry::validate_ping, ") ACE_TEXT ("transient, no more repings, ") ACE_TEXT ("server %C\n"), this->server_.c_str())); } if (this->listeners_.size() > 0) { this->update_listeners (); } return false; } } break; default:; } return true; }
void TAO_EC_Default_ProxyPushSupplier::connect_push_consumer ( RtecEventComm::PushConsumer_ptr push_consumer, const RtecEventChannelAdmin::ConsumerQOS& qos) { // Nil PushConsumers are illegal if (CORBA::is_nil (push_consumer)) throw CORBA::BAD_PARAM (); { ACE_GUARD_THROW_EX ( ACE_Lock, ace_mon, *this->lock_, CORBA::INTERNAL ()); // @@ RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); if (this->is_connected_i ()) { if (this->event_channel_->consumer_reconnect () == 0) throw RtecEventChannelAdmin::AlreadyConnected (); // Re-connections are allowed.... this->cleanup_i (); this->consumer_ = RtecEventComm::PushConsumer::_duplicate (push_consumer); this->qos_ = qos; this->child_ = this->event_channel_->filter_builder ()->build (this, this->qos_); this->adopt_child (this->child_); TAO_EC_Unlock reverse_lock (*this->lock_); { ACE_GUARD_THROW_EX ( TAO_EC_Unlock, ace_mon, reverse_lock, CORBA::INTERNAL ()); // @@ RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); this->event_channel_->reconnected (this); } // A separate thread could have connected simultaneously, // this is probably an application error, handle it as // gracefully as possible if (this->is_connected_i ()) return; // @@ Should we throw } #if (TAO_HAS_CORBA_MESSAGING == 1) if ( consumer_validate_connection_ == 1 ) { // Validate connection during connect. CORBA::PolicyList_var unused; int status = push_consumer->_validate_connection (unused); #if TAO_EC_ENABLE_DEBUG_MESSAGES ORBSVCS_DEBUG ((LM_DEBUG, "Validated connection to PushConsumer on connect. Status[%d]\n", status)); #else ACE_UNUSED_ARG(status); #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */ } #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ this->consumer_ = RtecEventComm::PushConsumer::_duplicate (push_consumer); this->qos_ = qos; #if TAO_EC_ENABLE_DEBUG_MESSAGES ORBSVCS_DEBUG ((LM_DEBUG, "Building filters for consumer <%x>.\n", this)); #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */ this->child_ = this->event_channel_->filter_builder ()->build (this, this->qos_); this->adopt_child (this->child_); } // Notify the event channel... this->event_channel_->connected (this); }
int TAO_UIPMC_Protocol_Factory::init (int argc, ACE_TCHAR* argv []) { ACE_Arg_Shifter arg_shifter (argc, argv); while (arg_shifter.is_anything_left ()) { const ACE_TCHAR *current_arg = 0; // This option lets you override the default if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBListenOnAll")))) { this->listen_on_all_ = !!ACE_OS::atoi (current_arg); arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBListenerInterfaces"))) || 0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBListenerInterface"))) || 0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBListenInterfaces"))) || 0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBListenInterface"))) ) { if (0 == ACE_OS::strcasecmp (current_arg, ACE_TEXT ("CopyPreferredInterfaces")) || 0 == ACE_OS::strcasecmp (current_arg, ACE_TEXT ("CopyPreferredInterface")) ) { // Add a special token (see TAO_UIPMC_Acceptor) which will be // subsituted (when we have access to the orb->params). if (this->listener_interfaces_.length ()) this->listener_interfaces_+= ','; this->listener_interfaces_+= CopyPreferredInterfaceToken; } else { const char *const always_char = ACE_TEXT_ALWAYS_CHAR (current_arg); if (TAO_ORB_Parameters::check_preferred_interfaces_string (always_char)) { // Append any valid string to those already specified // (by other -ORBListenerInterfaces options that have been // seen previously) if (this->listener_interfaces_.length ()) this->listener_interfaces_+= ','; this->listener_interfaces_+= always_char; } else ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO_UIPMC_Protocol_Factory::init - ") ACE_TEXT ("ignoring invalid -ORBListenerInterfaces %C\n"), always_char)); } arg_shifter.consume_arg (); } else { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO_UIPMC_Protocol_Factory::init - ") ACE_TEXT ("ignoring unknown option <%s>\n"), arg_shifter.get_current ())); arg_shifter.ignore_arg (); } } return 0; }
// FUZZ: disable check_for_ACE_Guard bool TAO_Notify_SequencePushConsumer::dispatch_from_queue (Request_Queue& requests, ACE_Guard <TAO_SYNCH_MUTEX> & ace_mon) // FUZZ: enable check_for_ACE_Guard { bool result = true; if (DEBUG_LEVEL > 0) { ORBSVCS_DEBUG ( (LM_DEBUG, ACE_TEXT ("(%P|%t) SequencePushConsumer dispatch queued requests. queue size:%u\n"), requests.size ())); } CORBA::ULong queue_size = ACE_Utils::truncate_cast<CORBA::ULong> (requests.size ()); CORBA::Long max_batch_size = queue_size; if (this->max_batch_size_.is_valid () ) { max_batch_size = this->max_batch_size_.value (); } CORBA::Long batch_size = queue_size; if (batch_size > max_batch_size) { batch_size = max_batch_size; } if (batch_size > 0) { CosNotification::EventBatch batch (batch_size); batch.length (batch_size); Request_Queue completed; CORBA::Long pos = 0; TAO_Notify_Method_Request_Event_Queueable * request = 0; while (pos < batch_size && requests.dequeue_head (request) == 0) { if (DEBUG_LEVEL > 0) { ORBSVCS_DEBUG ( (LM_DEBUG, ACE_TEXT ("(%P|%t) Sequence Dispatch Method_Request_Dispatch @%@\n"), request)); } const TAO_Notify_Event * ev = request->event (); ev->convert (batch [pos]); ++pos; // note enqueue at head, use queue as stack. completed.enqueue_head (request); } batch.length (pos); ACE_ASSERT (pos > 0); ace_mon.release (); bool from_timeout = false; TAO_Notify_Consumer::DispatchStatus status = this->dispatch_batch (batch); ace_mon.acquire (); switch (status) { case DISPATCH_SUCCESS: { TAO_Notify_Method_Request_Event_Queueable * request = 0; while (completed.dequeue_head (request) == 0) { request->complete (); request->release (); } result = true; break; } case DISPATCH_FAIL_TIMEOUT: from_timeout = true; // Fall through case DISPATCH_FAIL: { TAO_Notify_Method_Request_Event_Queueable * request = 0; while (completed.dequeue_head (request) == 0) { if (request->should_retry ()) { if (DEBUG_LEVEL > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Consumer %d: Will retry %d\n"), static_cast <int> (this->proxy ()->id ()), request->sequence ())); requests.enqueue_head (request); result = false; } else { if (DEBUG_LEVEL > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Consumer %d: Discarding %d\n"), static_cast<int> (this->proxy ()->id ()), request->sequence ())); request->complete (); request->release (); } } while (requests.dequeue_head (request) == 0) { if (request->should_retry ()) { if (DEBUG_LEVEL > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Consumer %d: Will retry %d\n"), static_cast<int> (this->proxy ()->id ()), request->sequence ())); requests.enqueue_head (request); result = false; } else { if (DEBUG_LEVEL > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Consumer %d: Discarding %d\n"), static_cast<int> (this->proxy ()->id ()), request->sequence ())); request->complete (); request->release (); } } ace_mon.release(); try { this->proxy_supplier ()->destroy (from_timeout); } catch (const CORBA::Exception&) { // todo is there something meaningful we can do here? ; } ace_mon.acquire(); break; } case DISPATCH_RETRY: case DISPATCH_DISCARD: { TAO_Notify_Method_Request_Event_Queueable * request = 0; while (completed.dequeue_head (request) == 0) { if (request->should_retry ()) { if (DEBUG_LEVEL > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Consumer %d: Will retry %d\n"), static_cast<int> (this->proxy ()->id ()), request->sequence ())); requests.enqueue_head (request); result = false; } else { if (DEBUG_LEVEL > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Consumer %d: Discarding %d\n"), static_cast<int> (this->proxy ()->id ()), request->sequence ())); request->complete (); request->release (); } } break; } default: { result = false; break; } } } return result; }
int TAO::FT_FaultNotifier_i::init (CORBA::ORB_ptr orb ) { int result = 0; this->orb_ = CORBA::ORB::_duplicate (orb); // Use the ROOT POA for now CORBA::Object_var poa_object = this->orb_->resolve_initial_references (TAO_OBJID_ROOTPOA); if (CORBA::is_nil (poa_object.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")), -1); // Get the POA object. this->poa_ = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil(this->poa_.in ())) { ORBSVCS_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" (%P|%t) Unable to narrow the POA.\n")), -1); } PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (); poa_manager->activate (); // Register with the POA. this->object_id_ = this->poa_->activate_object (this); // find my IOR CORBA::Object_var this_obj = this->poa_->id_to_reference (object_id_.in ()); this->ior_ = this->orb_->object_to_string (this_obj.in ()); //////////////////////////////////////////////// // Register with coresident Notification Channel CosNotifyChannelAdmin::EventChannelFactory_var notify_factory = TAO_Notify_EventChannelFactory_i::create (poa_.in ()); CosNotification::QoSProperties initial_qos; CosNotification::AdminProperties initial_admin; this->notify_channel_ = notify_factory->create_channel (initial_qos, initial_admin, channel_id_); this->filter_factory_ = this->notify_channel_->default_filter_factory (); /////////////////////////// // Producer registration this->supplier_admin_ = this->notify_channel_->default_supplier_admin (); ::CosNotifyChannelAdmin::ProxyID proxyId = 0; ////////////////////// // structured producer ::CosNotifyChannelAdmin::ProxyConsumer_var consumer = this->supplier_admin_->obtain_notification_push_consumer ( ::CosNotifyChannelAdmin::STRUCTURED_EVENT, proxyId); structured_proxy_push_consumer_ = ::CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(consumer.in ()); if (CORBA::is_nil (this->structured_proxy_push_consumer_.in ())) { ORBSVCS_ERROR_RETURN ((LM_ERROR, "%T %n (%P|%t) Should not occur: Unable to narrow Structured Proxy Push Consumer\n"), 1); } // todo: implement a push supplier if we want to receive disconnect notice CosNotifyComm::StructuredPushSupplier_var stubPushSupplier = CosNotifyComm::StructuredPushSupplier::_nil(); this->structured_proxy_push_consumer_->connect_structured_push_supplier (stubPushSupplier.in()); //////////////////// // Sequence producer consumer = this->supplier_admin_->obtain_notification_push_consumer ( ::CosNotifyChannelAdmin::SEQUENCE_EVENT, proxyId); this->sequence_proxy_push_consumer_ = ::CosNotifyChannelAdmin::SequenceProxyPushConsumer::_narrow(consumer.in ()); if (CORBA::is_nil (this->sequence_proxy_push_consumer_.in ())) { ORBSVCS_ERROR_RETURN ((LM_ERROR, "%T %n (%P|%t) Should not occur: Unable to narrow Sequence Proxy Push Consumer\n"), 1); } // todo: implement this if we want to receive disconnect notice CosNotifyComm::SequencePushSupplier_var stubSeqPushSupplier = CosNotifyComm::SequencePushSupplier::_nil(); this->sequence_proxy_push_consumer_->connect_sequence_push_supplier (stubSeqPushSupplier.in()); /////////////////////////// // Consumer registration // find the channel administrator for consumers this->consumer_admin_ = this->notify_channel_->default_consumer_admin (); if (CORBA::is_nil (this->consumer_admin_.in ())) { ORBSVCS_ERROR ((LM_ERROR, "%T %n (%P|%t) NIL consumer admin\n" )); result = -1; } // everything else happens when subscriber shows up /////////////////////////////// // Register with ReplicationManager if (this->rm_register_) { try { CORBA::Object_var rm_obj = orb->resolve_initial_references("ReplicationManager"); this->replication_manager_ = ::FT::ReplicationManager::_narrow(rm_obj.in()); if (!CORBA::is_nil (replication_manager_.in ())) { // @@: should we check to see if there's already one registered? FT::FaultNotifier_var notifier = FT::FaultNotifier::_narrow (this_obj.in ()); if (! CORBA::is_nil (notifier.in ())) { this->replication_manager_->register_fault_notifier(notifier.in ()); ORBSVCS_DEBUG ((LM_DEBUG, "FaultNotifier registered with ReplicationManager.\n" )); this->registered_ = 1; } else { ORBSVCS_ERROR ((LM_ERROR, "Error: Registration failed. This is not a FaultNotifier (should not occur.)\n" )); } } else { ORBSVCS_ERROR ((LM_ERROR,"FaultNotifier: Can't resolve ReplicationManager, It will not be registered.\n" )); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "FaultNotifier: Exception resolving ReplicationManager. Notifier will not be registered.\n"); } } else { ORBSVCS_DEBUG ((LM_DEBUG, "FaultNotifier: ReplicationManager registration disabled.\n" )); } /////////////////////////////// // Set up and ready for action // publish our IOR if(result == 0) { if (this->ior_output_file_ != 0) { this->identity_ = "file:"; this->identity_ += ACE_TEXT_ALWAYS_CHAR(this->ior_output_file_); result = write_ior(); } } if (result == 0) { if (this->ns_name_ != 0) { this->identity_ = "name:"; this->identity_ += this->ns_name_; CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService"); if (CORBA::is_nil(naming_obj.in ())) { ORBSVCS_ERROR_RETURN ((LM_ERROR, "%T %n (%P|%t) Unable to find the Naming Service\n"), 1); } this->naming_context_ = CosNaming::NamingContext::_narrow (naming_obj.in ()); if (CORBA::is_nil(this->naming_context_.in ())) { ORBSVCS_ERROR_RETURN ((LM_ERROR, "%T %n (%P|%t) Should not occur: Can't narrow initial reference to naming context.\n"), 1); } this->this_name_.length (1); this->this_name_[0].id = CORBA::string_dup (this->ns_name_); this->naming_context_->rebind (this->this_name_, this_obj.in() //CORBA::Object::_duplicate(this_obj) ); } } return result; }
int TAO_AV_Callback::handle_destroy (void) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,"TAO_AV_Callback::handle_end_stream\n")); return -1; }
DsLogAdmin::RecordList* TAO_Hash_LogRecordStore::query_i (const char *constraint, DsLogAdmin::Iterator_out &iter_out, CORBA::ULong how_many) { // Use an Interpreter to build an expression tree. TAO_Log_Constraint_Interpreter interpreter (constraint); // Sequentially iterate over all the records and pick the ones that // meet the constraints. // Allocate the list of <how_many> length. DsLogAdmin::RecordList* rec_list; ACE_NEW_THROW_EX (rec_list, DsLogAdmin::RecordList (how_many), CORBA::NO_MEMORY ()); rec_list->length(how_many); // Create iterators LOG_RECORD_STORE_ITER iter (rec_map_.begin ()); LOG_RECORD_STORE_ITER iter_end (rec_map_.end ()); CORBA::ULong count = 0; // count of matches found. for ( ; ((iter != iter_end) && (count < how_many)); ++iter) { // Use an evaluator. TAO_Log_Constraint_Visitor evaluator (iter->item ()); // Does it match the constraint? if (interpreter.evaluate (evaluator) == 1) { if (TAO_debug_level > 0) { ORBSVCS_DEBUG ((LM_DEBUG,"Matched constraint! d = %Q, Time = %Q\n", iter->item ().id, iter->item ().time)); } (*rec_list)[count] = iter->item (); // copy the log record. ++count; } } rec_list->length (count); if (iter != iter_end) // There are more records to process. { // Create an iterator to pass out. TAO_Hash_Iterator_i *iter_query = 0; ACE_NEW_THROW_EX (iter_query, TAO_Hash_Iterator_i (this->iterator_poa_.in (), this->reactor_, this, iter, iter_end, count, constraint, this->max_rec_list_len_), CORBA::NO_MEMORY ()); // Transfer ownership to the POA. PortableServer::ServantBase_var safe_iter_query = iter_query; // Activate it. PortableServer::ObjectId_var oid = this->iterator_poa_->activate_object (iter_query); CORBA::Object_var obj = this->iterator_poa_->id_to_reference (oid.in ()); // Narrow it iter_out = DsLogAdmin::Iterator::_narrow (obj.in ()); } return rec_list; }
void PingReceiver::ping_excep (Messaging::ExceptionHolder * excep_holder) { const CORBA::ULong TAO_MINOR_MASK = 0x00000f80; try { if (ImR_Locator_i::debug () > 5) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) PingReceiver::ping_excep received from %C\n"), this->entry_->server_name ())); } excep_holder->raise_exception (); } catch (const CORBA::TRANSIENT &ex) { switch (ex.minor () & TAO_MINOR_MASK) { case TAO_POA_DISCARDING: case TAO_POA_HOLDING: { if (this->entry_ != 0) { this->entry_->release_callback (); this->entry_->status (LS_TRANSIENT); } break; } default: //case TAO_INVOCATION_SEND_REQUEST_MINOR_CODE: { if (this->entry_ != 0) { this->entry_->release_callback (); this->entry_->status (LS_DEAD); } } } } catch (const CORBA::TIMEOUT &ex) { if (this->entry_ != 0) { this->entry_->release_callback (); if ((ex.minor () & TAO_MINOR_MASK) == TAO_TIMEOUT_CONNECT_MINOR_CODE) { this->entry_->status (LS_DEAD); } else { this->entry_->status (LS_TIMEDOUT); } } } catch (const CORBA::Exception &) { if (this->entry_ != 0) { this->entry_->release_callback (); this->entry_->status (LS_DEAD); } } PortableServer::ObjectId_var oid = this->poa_->servant_to_id (this); poa_->deactivate_object (oid.in()); }
int TAO::SSLIOP::Acceptor::ssliop_open_i (TAO_ORB_Core *orb_core, const ACE_INET_Addr& addr, ACE_Reactor *reactor) { this->orb_core_ = orb_core; ACE_NEW_RETURN (this->creation_strategy_, CREATION_STRATEGY (this->orb_core_), -1); ACE_NEW_RETURN (this->concurrency_strategy_, CONCURRENCY_STRATEGY (this->orb_core_), -1); ACE_NEW_RETURN (this->accept_strategy_, ACCEPT_STRATEGY (this->orb_core_, this->timeout_), -1); u_short requested_port = addr.get_port_number (); if (requested_port == 0) { // don't care, i.e., let the OS choose an ephemeral port if (this->ssl_acceptor_.open (addr, reactor, this->creation_strategy_, this->accept_strategy_, this->concurrency_strategy_, 0, 0, 0, 1, this->reuse_addr_) == -1) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\nTAO (%P|%t) ") ACE_TEXT ("SSLIOP_Acceptor::open_i - %p\n\n"), ACE_TEXT ("cannot open acceptor"))); return -1; } } else { ACE_INET_Addr a(addr); int found_a_port = 0; ACE_UINT32 last_port = requested_port + this->port_span_ - 1; if (last_port > ACE_MAX_DEFAULT_PORT) { last_port = ACE_MAX_DEFAULT_PORT; } for (ACE_UINT32 p = requested_port; p <= last_port; p++) { if (TAO_debug_level > 5) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) IIOP_Acceptor::open_i() ") ACE_TEXT ("trying to listen on port %d\n"), p)); // Now try to actually open on that port a.set_port_number ((u_short)p); if (this->ssl_acceptor_.open (a, reactor, this->creation_strategy_, this->accept_strategy_, this->concurrency_strategy_, 0, 0, 0, 1, this->reuse_addr_) != -1) { found_a_port = 1; break; } } // Now, if we couldn't locate a port, we punt if (! found_a_port) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\nTAO (%P|%t) ") ACE_TEXT ("SSLIOP_Acceptor::open_i - %p\n\n"), ACE_TEXT ("cannot open acceptor"))); return -1; } } ACE_INET_Addr ssl_address; // We do this to make sure the port number the endpoint is listening // on gets set in the addr. if (this->ssl_acceptor_.acceptor ().get_local_addr (ssl_address) != 0) { // @@ Should this be a catastrophic error??? if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\nTAO (%P|%t) ") ACE_TEXT ("SSLIOP_Acceptor::open_i - %p\n\n"), ACE_TEXT ("cannot get local addr"))); return -1; } // Reset the SSL endpoint port to the one chosen by the OS (or by // the user if provided. this->ssl_component_.port = ssl_address.get_port_number (); (void) this->ssl_acceptor_.acceptor().enable (ACE_CLOEXEC); // This avoids having child processes acquire the listen socket // thereby denying the server the opportunity to restart on a // well-known endpoint. This does not affect the aberrent behavior // on Win32 platforms. if (TAO_debug_level > 5) { for (size_t i = 0; i < this->endpoint_count_; ++i) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) ") ACE_TEXT ("SSLIOP_Acceptor::open_i - ") ACE_TEXT ("listening on: <%C:%u>\n"), this->hosts_[i], this->ssl_component_.port)); } } // In the event that an accept() fails, we can examine the reason. If // the reason warrants it, we can try accepting again at a later time. // The amount of time we wait to accept again is governed by this orb // parameter. this->set_error_retry_delay ( this->orb_core_->orb_params ()->accept_error_delay()); return 0; }
int LiveCheck::handle_timeout (const ACE_Time_Value &, const void * tok) { LC_token_type token = reinterpret_cast<LC_token_type>(tok); if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::handle_timeout(%d), ") ACE_TEXT ("running = %d\n"), token, this->running_)); } if (!this->running_) return -1; LC_TimeoutGuard tg (this, token); if (tg.blocked ()) return 0; LiveEntryMap::iterator le_end = this->entry_map_.end(); for (LiveEntryMap::iterator le = this->entry_map_.begin(); le != le_end; ++le) { LiveEntry *entry = le->item (); if (entry->validate_ping (this->want_timeout_, this->deferred_timeout_)) { entry->do_ping (poa_.in ()); if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::handle_timeout(%d)") ACE_TEXT (", ping sent\n"), token)); } } else { if (ImR_Locator_i::debug () > 4) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::handle_timeout(%d)") ACE_TEXT (", ping skipped\n"), token)); } } } PerClientStack::iterator pe_end = this->per_client_.end(); for (PerClientStack::iterator pe = this->per_client_.begin(); pe != pe_end; ++pe) { LiveEntry *entry = *pe; if (entry != 0) { if (entry->validate_ping (this->want_timeout_, this->deferred_timeout_)) { entry->do_ping (poa_.in ()); } LiveStatus status = entry->status (); if (status != LS_PING_AWAY && status != LS_TRANSIENT) { this->per_client_.remove (entry); delete entry; } } } return 0; }
void TAO::PG_Object_Group::add_member (const PortableGroup::Location & the_location, CORBA::Object_ptr member) { ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); if (CORBA::is_nil (member)) { if (TAO_debug_level > 3) { ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("%T %n (%P|%t) - TAO::PG_Object_Group::add_member") ACE_TEXT ("Can't add a null member to object group\n") )); } throw PortableGroup::ObjectNotAdded (); } ///////////////////////////////////////// // Convert the new member to a string IOR // This keeps a clean IOR (not an IOGR!) // while we add it to a group. We need a // IORs, not IOGRs to send new IOGRs out // to replicas. // Verify that the member is not using V1.0 profiles // since IIOP V1.0 does not support tagged components const TAO_MProfile &member_profiles = member->_stubobj ()->base_profiles (); CORBA::ULong member_profile_count = member_profiles.profile_count (); if (member_profile_count > 0) { const TAO_GIOP_Message_Version & version = member_profiles.get_profile (0)->version (); if (version.major_version () == 1 && version.minor_version () == 0) { if (TAO_debug_level > 3) { ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("%T %n (%P|%t) - ") ACE_TEXT ("Can't add member because first profile ") ACE_TEXT ("is IIOP version 1.0, which does not ") ACE_TEXT ("support tagged components.\n") )); } throw PortableGroup::ObjectNotAdded (); } } CORBA::String_var member_ior_string = orb_->object_to_string (member); PortableGroup::ObjectGroup_var new_reference; try { new_reference = this->add_member_to_iogr (member); } catch (const TAO_IOP::Duplicate&) { throw PortableGroup::MemberAlreadyPresent (); } catch (const TAO_IOP::Invalid_IOR&) { throw PortableGroup::ObjectNotAdded (); } catch (...) { throw; } if (CORBA::is_nil (new_reference.in ())) throw PortableGroup::ObjectNotAdded (); // Convert new member back to a (non group) ior. CORBA::Object_var member_ior = this->orb_->string_to_object (member_ior_string.in ()); MemberInfo * info = 0; ACE_NEW_THROW_EX (info, MemberInfo (member_ior.in (), the_location), CORBA::NO_MEMORY()); if (this->members_.bind (the_location, info) != 0) { delete info; // @@ Dale why this is a NO MEMORY exception? throw CORBA::NO_MEMORY(); } this->reference_ = new_reference; // note var-to-var assignment does // a duplicate if (this->increment_version ()) { this->distribute_iogr (); } else { // Issue with incrementing the version if (TAO_debug_level > 6) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("PG (%P|%t) Issue incrementing the ") ACE_TEXT ("version in Object_Group add_member\n"))); } // Must unbind the new member and delete it. if (this->members_.unbind (the_location, info) == 0) delete info; throw PortableGroup::ObjectNotAdded (); } if (TAO_debug_level > 6) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("PG (%P|%t) exit Object_Group add_member\n"))); } }
bool LiveCheck::schedule_ping (LiveEntry *entry) { if (!this->running_) return false; LiveStatus status = entry->status(); if (status == LS_PING_AWAY || status == LS_DEAD) { return status != LS_DEAD; } ACE_Time_Value now (ACE_High_Res_Timer::gettimeofday_hr()); ACE_Time_Value next = entry->next_check (); if (this->handle_timeout_busy_ > 0) { ACE_Time_Value delay = ACE_Time_Value::zero; if (next > now) { delay = next - now; } ACE_Timer_Queue *tq = this->reactor ()->timer_queue (); if (!tq->is_empty ()) { for (ACE_Timer_Queue_Iterator_T<ACE_Event_Handler*> &i = tq->iter (); !i.isdone (); i.next()) { if (i.item ()->get_type () == this) { if (next >= tq->earliest_time ()) { if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::schedule_ping ") ACE_TEXT ("already scheduled\n"))); } return true; } break; } } } ++this->token_; if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::schedule_ping (%d),") ACE_TEXT (" delay = %d,%d\n"), this->token_, delay.sec(), delay.usec())); } this->reactor()->schedule_timer (this, reinterpret_cast<void *>(this->token_), delay); } else { if (ImR_Locator_i::debug () > 2) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::schedule_ping deferred"))); } if (!this->want_timeout_ || next < this->deferred_timeout_) { this->want_timeout_ = true; this->deferred_timeout_ = next; } } return true; }
////////////////// // Internal method void TAO::PG_Object_Group::distribute_iogr (void) { // Check if the object group is configured to distribute if (!this->distribute_) return; // assume internals is locked CORBA::String_var iogr = this->orb_->object_to_string (this->reference_.in()); // size_t n_rep = 0; // for dump_ior below for (MemberMap_Iterator it = this->members_.begin(); it != this->members_.end (); ++it) { MemberInfo const * info = (*it).int_id_; // // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_); // but it doesn work: error message at replica is: // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0] // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed // back to using _narrow PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_.in ()); if (!CORBA::is_nil (uog.in ())) { try { if (TAO_debug_level > 3) { ORBSVCS_DEBUG ((LM_DEBUG, "PG (%P|%t) - Object_Group pushing " "IOGR to %s member: %s@%s.\n", (info->is_primary_ ? "Primary" : "Backup"), this->role_.c_str (), static_cast<const char *> (info->location_[0].id) )); } // dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr); // CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in()); // dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior); uog->tao_update_object_group (iogr.in (), this->tagged_component_.object_group_ref_version, info->is_primary_); } catch (const CORBA::Exception&) { // we expect an exception // tao_update_object_group is not a real method } } else { ORBSVCS_ERROR ((LM_ERROR, "TAO::PG_Object_Group::distribute iogr can't " "narrow member reference to " "PortableGroup::TAO_UpdateObjectGroup.\n" )); } } }
ACE_HANDLE TAO_AV_UDP_MCast_Flow_Handler::get_handle (void) const { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,"TAO_AV_UDP_MCast_Flow_Handler::get_handle ")); return this->get_mcast_socket ()->get_handle () ; }
int Task_Entry::disjunctive_merge (Dependency_Type dt, ACE_Unbounded_Set <Dispatch_Entry *> &dispatch_entries, ACE_CString &unresolved_locals, ACE_CString &unresolved_remotes) { char string_buffer[BUFSIZ]; // Iterate over the set of dependencies, merging dispatches of the // callers over the enclosing frame size. for (ACE_Unbounded_Set_Iterator <Task_Entry_Link *> iter (callers_); ! iter.done (); iter.advance ()) { Task_Entry_Link **link; if (iter.next (link) == 0 || link == 0 || *link == 0) return -1; // The link matches the dependency type given if ((*link)->dependency_type () == dt) { // Check for and warn about unresolved remote dependencies // in the ONE_WAY call graph. if ((*link)->dependency_type () == RtecBase::ONE_WAY_CALL && (*link)->caller ().has_unresolved_remote_dependencies () && ! this->has_unresolved_remote_dependencies ()) { // Propagate the unresolved remote dependency flag, and // issue a debug scheduler warning. this->has_unresolved_remote_dependencies (1); ORBSVCS_DEBUG ((LM_DEBUG, "Warning: an operation identified by " "\"%s\" has unresolved remote dependencies.\n", (const char*) this->rt_info ()->entry_point)); // Record entry point in list of unresolved remote // dependencies ACE_OS::sprintf (string_buffer, "// %s\n", (const char*) this->rt_info ()->entry_point); unresolved_remotes += ACE_CString (string_buffer); } // Check for and warn about unresolved local dependencies in // the ONE_WAY call graph. if ((*link)->dependency_type () == RtecBase::ONE_WAY_CALL && (*link)->caller ().has_unresolved_local_dependencies () && ! this->has_unresolved_local_dependencies ()) { // Propagate the unresolved local dependency flag, and // issue a debug scheduler warning. this->has_unresolved_local_dependencies (1); ORBSVCS_DEBUG ((LM_DEBUG, "Warning: an operation identified by " "\"%s\" has unresolved local dependencies.\n", (const char*) this->rt_info ()->entry_point)); // Record entry point in list of unresolved local // dependencies ACE_OS::sprintf (string_buffer, "// %s\n", (const char*) this->rt_info ()->entry_point); unresolved_locals += ACE_CString (string_buffer); } // Merge the caller's dispatches into the current set. if (merge_frames (dispatch_entries, *this, dispatches_, (*link)->caller ().dispatches_, effective_period_, (*link)->caller ().effective_period_, (*link)->number_of_calls ()) < 0) return -1; } } return 0; }
void TAO_Notify_PushConsumer::init (CosEventComm::PushConsumer_ptr push_consumer) { // Initialize only once ACE_ASSERT( CORBA::is_nil (this->push_consumer_.in()) ); // push_consumer not optional if (CORBA::is_nil (push_consumer)) { throw CORBA::BAD_PARAM(); } try { if (!TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb ()) { this->push_consumer_ = CosEventComm::PushConsumer::_duplicate (push_consumer); this->publish_ = CosNotifyComm::NotifyPublish::_narrow (push_consumer); } else { // "Port" consumer's object reference from receiving ORB to dispatching ORB. CORBA::String_var temp = TAO_Notify_PROPERTIES::instance()->orb()->object_to_string(push_consumer); CORBA::Object_var obj = TAO_Notify_PROPERTIES::instance()->dispatching_orb()->string_to_object(temp.in()); CosEventComm::PushConsumer_var new_cos_comm_pc = CosEventComm::PushConsumer::_unchecked_narrow(obj.in()); this->push_consumer_ = CosEventComm::PushConsumer::_duplicate (new_cos_comm_pc.in()); // // Note that here we do an _unchecked_narrow() in order to avoid // making a call on the consumer b/c the consumer may not have activated // its POA just yet. That means that before we use this reference the first // time, we'll actually need to call _is_a() on it, i.e., the equivalent // of an _narrow(). At the time of this writing, the only use of // this->publish_ is in TAO_NS_Consumer::dispatch_updates_i (the superclass). // If any other use is made of this data member, then the code to validate // the actual type of the target object must be refactored. this->publish_ = CosNotifyComm::NotifyPublish::_unchecked_narrow (obj.in()); //--cj verify dispatching ORB if (TAO_debug_level >= 10) { ORBSVCS_DEBUG ((LM_DEBUG, "(%P|%t) Any push init dispatching ORB id is %s.\n", obj->_stubobj()->orb_core()->orbid())); } //--cj end } } catch (const CORBA::TRANSIENT& ex) { ex._tao_print_exception ("Got a TRANSIENT in NS_PushConsumer::init"); ORBSVCS_DEBUG ((LM_DEBUG, "(%P|%t) got it for NS_PushConsumer %@\n", this)); } catch (const CORBA::Exception&) { // _narrow failed which probably means the interface is CosEventComm type. } }
Delivery_Request::~Delivery_Request () { if (DEBUG_LEVEL > 8) ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Delivery_Request:: destructor\n") )); }
int Event_Service::parse_args (int argc, ACE_TCHAR* argv []) { // default values... this->service_name_ = "EventService"; ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("an:o:p:s:q:bx")); int opt; while ((opt = get_opt ()) != EOF) { switch (opt) { case 'a': // This is processed in main() break; case 'n': this->service_name_ = ACE_TEXT_ALWAYS_CHAR(get_opt.opt_arg ()); break; case 'o': this->ior_file_name_ = get_opt.opt_arg (); break; case 'p': this->pid_file_name_ = get_opt.opt_arg (); break; case 'q': this->object_id_ = ACE_TEXT_ALWAYS_CHAR(get_opt.opt_arg ()); break; case 'b': this->use_bidir_giop_ = true; break; case 'x': this->bind_to_naming_service_ = false; break; case 's': // It could be just a flag (i.e. no "global" or "local" // argument, but this is consistent with the EC_Multiple // test and also allows for a runtime scheduling service. if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT("global")) == 0) { this->scheduler_type_ = ES_SCHED_GLOBAL; } else if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT("local")) == 0) { this->scheduler_type_ = ES_SCHED_LOCAL; } else if (ACE_OS::strcasecmp (get_opt.opt_arg (), ACE_TEXT("none")) == 0) { this->scheduler_type_ = ES_SCHED_NONE; } else { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("Unknown scheduling type <%s> ") ACE_TEXT("defaulting to none\n"), get_opt.opt_arg ())); this->scheduler_type_ = ES_SCHED_NONE; } break; case '?': default: ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("Usage: %s ") ACE_TEXT("-a ") ACE_TEXT("-n service_name ") ACE_TEXT("-o ior_file_name ") ACE_TEXT("-p pid_file_name ") ACE_TEXT("-s <global|local|none> ") ACE_TEXT("-q ec_object_id ") ACE_TEXT("-x [disable naming service bind] ") ACE_TEXT("-b [use bidir giop] ") ACE_TEXT("\n"), argv[0])); return -1; } } return 0; }
int TAO_AV_Core::init_reverse_flows (TAO_Base_StreamEndPoint *endpoint, TAO_AV_FlowSpecSet &forward_flow_spec_set, TAO_AV_FlowSpecSet &reverse_flow_spec_set, TAO_AV_Core::EndPoint direction) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Core::init_reverse_flows\n")); TAO_AV_FlowSpecSet acceptor_flow_set; TAO_AV_FlowSpecSet connector_flow_set; TAO_AV_FlowSpecSetItor end = reverse_flow_spec_set.end (); TAO_AV_FlowSpecSetItor start = reverse_flow_spec_set.begin (); for (;start != end; ++start) { TAO_FlowSpec_Entry *entry = (*start); ACE_Addr *address = entry->address (); switch (direction) { case TAO_AV_Core::TAO_AV_ENDPOINT_B: { switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_IN: entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER); break; case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT: entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER); break; } break; } case TAO_AV_Core::TAO_AV_ENDPOINT_A: { switch (entry->direction ()) { case TAO_FlowSpec_Entry::TAO_AV_DIR_IN: entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER); break; case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT: entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER); break; } break; } default: break; } if (address != 0) { if (this->get_acceptor (entry->flowname ())!= 0) { ACE_Addr *address = entry->address (); TAO_FlowSpec_Entry *forward_entry = this->get_flow_spec_entry (forward_flow_spec_set, entry->flowname ()); if (forward_entry != 0) forward_entry->set_peer_addr (address); } else connector_flow_set.insert (entry); } } int result = -1; switch (direction) { case TAO_AV_Core::TAO_AV_ENDPOINT_A: { result = this->connector_registry_->open (endpoint, this, connector_flow_set); } break; default: break; } if (result == -1) ORBSVCS_ERROR_RETURN ((LM_ERROR,"acceptor_registry::open"),-1); return 0; }
int Event_Service::run (int argc, ACE_TCHAR* argv[]) { try { // Check if -ORBDaemon is specified and if so, daemonize at this moment, // -ORBDaemon in the ORB core is faulty, see bugzilla 3335 TAO_Daemon_Utility::check_for_daemon (argc, argv); // Initialize ORB. this->orb_ = CORBA::ORB_init (argc, argv); if (this->parse_args (argc, argv) == -1) return 1; CORBA::Object_var root_poa_object = this->orb_->resolve_initial_references("RootPOA"); if (CORBA::is_nil (root_poa_object.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the root POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (root_poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); // When we have a service name or a non local scheduler we must use the // naming service. bool use_name_service = bind_to_naming_service_ || this->scheduler_type_ != ES_SCHED_NONE; CORBA::Object_var naming_obj; RtecScheduler::Scheduler_var scheduler; CosNaming::NamingContext_var naming_context; if (use_name_service) { naming_obj= this->orb_->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the Naming Service.\n"), 1); naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ()); } // This is the name we (potentially) register the Scheduling // Service in the Naming Service. CosNaming::Name schedule_name (1); schedule_name.length (1); schedule_name[0].id = CORBA::string_dup ("ScheduleService"); // The old EC always needs a scheduler. If none is // specified, we default to a local scheduler if (this->scheduler_type_ == ES_SCHED_LOCAL) { // Create a local scheduler instance ACE_NEW_RETURN (this->sched_impl_, ACE_Config_Scheduler, 1); scheduler = this->sched_impl_->_this (); // Register the servant with the Naming Context.... if (!CORBA::is_nil (naming_context.in ())) { naming_context->rebind (schedule_name, scheduler.in ()); } } else if (this->scheduler_type_ == ES_SCHED_GLOBAL) { // Get reference to a scheduler from naming service CORBA::Object_var tmp = naming_context->resolve (schedule_name); scheduler = RtecScheduler::Scheduler::_narrow (tmp.in ()); if (CORBA::is_nil (scheduler.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to resolve the Scheduling Service.\n"), 1); } TAO_EC_Event_Channel_Attributes attr (root_poa.in (), root_poa.in ()); if (this->scheduler_type_ != ES_SCHED_NONE) { attr.scheduler = scheduler.in (); } TAO_EC_Event_Channel* ec_impl = 0; ACE_NEW_RETURN (ec_impl, TAO_EC_Event_Channel (attr), 1); this->ec_impl_ = ec_impl; ec_impl->activate (); RtecEventChannelAdmin::EventChannel_var ec; // If the object_id_ is empty and we don't use BiDIR GIOP, activate the // servant under the default POA, else create a new child POA with // the needed policies int persistent = ACE_OS::strcmp(this->object_id_.c_str(), ""); if ((persistent == 0) && (this->use_bidir_giop_ == false)) { // Notice that we activate *this* object with the POA, but we // forward all the requests to the underlying EC // implementation. ec = this->_this (); } else { CORBA::ULong index = 0; // Create child POA CORBA::PolicyList policies (3); if (persistent != 0) { policies.length (index++); policies[index] = root_poa->create_id_assignment_policy (PortableServer::USER_ID); policies.length (index++); policies[index] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT); } if (this->use_bidir_giop_ == true) { CORBA::Any pol; pol <<= BiDirPolicy::BOTH; policies.length (index++); policies[index] = this->orb_->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, pol); } ACE_CString child_poa_name = "childPOA"; PortableServer::POA_var child_poa = root_poa->create_POA (child_poa_name.c_str (), poa_manager.in (), policies); // Creation of persistentPOA is over. Destroy the Policy objects. for (CORBA::ULong i = 0; i < policies.length (); ++i) { policies[i]->destroy (); } if (CORBA::is_nil (child_poa.in ())) ORBSVCS_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the child POA.\n"), 1); PortableServer::ObjectId_var ec_object_id = PortableServer::string_to_ObjectId(object_id_.c_str()); child_poa->activate_object_with_id(ec_object_id.in(), this); CORBA::Object_var ec_obj = child_poa->id_to_reference(ec_object_id.in()); ec = RtecEventChannelAdmin::EventChannel::_narrow(ec_obj.in()); } CORBA::String_var str = this->orb_->object_to_string (ec.in ()); if (ACE_OS::strcmp(this->ior_file_name_.c_str(), ACE_TEXT("")) != 0) { FILE *output_file= ACE_OS::fopen (this->ior_file_name_.c_str(), ACE_TEXT("w")); if (output_file == 0) ORBSVCS_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", this->ior_file_name_.c_str()), 1); ACE_OS::fprintf (output_file, "%s", str.in ()); ACE_OS::fclose (output_file); } if (ACE_OS::strcmp(this->pid_file_name_.c_str(), ACE_TEXT("")) != 0) { FILE *pidf = ACE_OS::fopen (this->pid_file_name_.c_str(), ACE_TEXT("w")); if (pidf != 0) { ACE_OS::fprintf (pidf, "%ld\n", static_cast<long> (ACE_OS::getpid ())); ACE_OS::fclose (pidf); } } ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("The EC IOR is <%C>\n"), str.in ())); if (bind_to_naming_service_ && !CORBA::is_nil (naming_context.in ())) { CosNaming::Name channel_name (1); channel_name.length (1); channel_name[0].id = CORBA::string_dup (this->service_name_.c_str()); naming_context->rebind (channel_name, ec.in ()); } ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT("%C; running event service\n"), __FILE__)); this->orb_->run (); if (bind_to_naming_service_ && !CORBA::is_nil (naming_context.in ())) { CosNaming::Name channel_name (1); channel_name.length (1); channel_name[0].id = CORBA::string_dup (this->service_name_.c_str()); naming_context->unbind (channel_name); } if (!CORBA::is_nil (scheduler.in ()) && !CORBA::is_nil (naming_context.in ())) { naming_context->unbind (schedule_name); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("EC"); } return 0; }
int TAO_AV_SCTP_SEQ_Connector::connect (TAO_FlowSpec_Entry *entry, TAO_AV_Transport *&transport, TAO_AV_Core::Flow_Component flow_comp) { this->entry_ = entry; if (flow_comp == TAO_AV_Core::TAO_AV_CONTROL) this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname ()); else this->flowname_ = entry->flowname (); ACE_Addr *remote_addr = entry->address (); ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr *> (remote_addr); TAO_AV_SCTP_SEQ_Flow_Handler *handler = 0; ACE_Multihomed_INET_Addr remote_multi_addr; remote_multi_addr.set (inet_addr->get_port_number (), inet_addr->get_ip_address (), 1, 0, 0); ACE_Multihomed_INET_Addr local_addr; //This can be a multihomed address ACE_INET_Addr *addr; if (entry->get_peer_addr () != 0) { addr = dynamic_cast<ACE_INET_Addr *> (entry->get_peer_addr ()); } else { ACE_NEW_RETURN (addr, ACE_INET_Addr ("0"), -1); } ACE_Auto_Array_Ptr<ACE_UINT32> local_ip_addr (new ACE_UINT32[entry->num_peer_sec_addrs ()]); ACE_INET_Addr ip_addr; char** addrs = entry->get_peer_sec_addr (); for (int i = 0; i < entry->num_peer_sec_addrs (); i++) { ACE_CString addr_str (addrs[i]); addr_str += ":"; ip_addr.set (addr_str.c_str ()); local_ip_addr[i] = ip_addr.get_ip_address (); } if (entry->num_peer_sec_addrs () != 0) local_addr.set (addr->get_port_number (), addr->get_ip_address (), 1, local_ip_addr.get(), entry->num_peer_sec_addrs ()); else local_addr.set (addr->get_port_number (), addr->get_ip_address (), 1, 0, entry->num_peer_sec_addrs ()); int result = this->connector_.connector_connect (handler, remote_multi_addr, local_addr); if (result < 0) ORBSVCS_ERROR_RETURN ((LM_ERROR,"TAO_AV_SCTP_SEQ_connector::connect failed\n"),-1); entry->handler (handler); transport = handler->transport (); if (TAO_debug_level > 0) { ORBSVCS_DEBUG ((LM_DEBUG, "Local Addrs\n")); char buf [BUFSIZ]; size_t size = BUFSIZ; ACE_INET_Addr *peer_addrs = 0; ACE_NEW_RETURN (peer_addrs,ACE_INET_Addr [size], -1); handler->peer ().get_local_addrs (peer_addrs, size); for (unsigned int i=0; i < size; i++) { peer_addrs [i].addr_to_string (buf, BUFSIZ); ORBSVCS_DEBUG ((LM_DEBUG, "%s %d\n", buf, size)); } ORBSVCS_DEBUG ((LM_DEBUG, "Remote Addrs\n")); size = BUFSIZ; handler->peer ().get_remote_addrs (peer_addrs, size); for (unsigned int i=0; i < size; i++) { peer_addrs [i].addr_to_string (buf, BUFSIZ); ORBSVCS_DEBUG ((LM_DEBUG, "%s %d\n", buf, size)); } //delete peer_addrs; } return 0; }
int TAO_AV_Callback::handle_timeout (void * /*arg*/) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG,"TAO_AV_Callback::handle_timeout\n")); return 0; }