static int run_tests (int iterations, FILE *input_fp, FILE *output_fp) { int i = 0; ACE_NEW_RETURN (test_vector[i], Stdio_Test ("Stdio_Test", profile_timer), -1); i++; ACE_NEW_RETURN (test_vector[i], Block_Fread_Fwrite_Test ("Block_Fread_Fwrite_Test", profile_timer), -1); i++; ACE_NEW_RETURN (test_vector[i], Block_Read_Write_Test ("Block_Read_Write_Test", profile_timer), -1); i++; ACE_NEW_RETURN (test_vector[i], Mmap1_Test ("Mmap1_Test", profile_timer), -1); i++; ACE_NEW_RETURN (test_vector[i], Mmap2_Test ("Mmap2_Test", profile_timer), -1); i++; ACE_NEW_RETURN (test_vector[i], Slow_Read_Write_Test ("Slow_Read_Write_Test", profile_timer), -1); i++; test_vector[i] = (IO_Test *) 0; for (i = 0; test_vector[i] != 0; i++) { ACE_HANDLE hfile = fileno (output_fp); if (ACE_OS::ftruncate (hfile, 0) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%s\n", "ftruncate"), -1); ACE_DEBUG ((LM_DEBUG, "--------------------\n" "starting %s for %d iterations(s):\n", test_vector[i]->name (), iterations)); test_vector[i]->run_test (iterations, input_fp, output_fp); ACE_Profile_Timer::ACE_Elapsed_Time et; profile_timer.elapsed_time (et); ACE_DEBUG ((LM_DEBUG, "wallclock time = %f, user time = %f, system time = %f\n", et.real_time, et.user_time, et.system_time)); delete test_vector[i]; } ACE_DEBUG ((LM_DEBUG, "--------------------\n")); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { Server_ORBInitializer2 *temp_initializer = 0; ACE_NEW_RETURN (temp_initializer, Server_ORBInitializer2, -1); // No 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); 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 (); CORBA::PolicyList policies (2); policies.length (2); policies[0] = root_poa->create_id_assignment_policy (PortableServer::USER_ID); policies[1] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT); PortableServer::POA_var my_poa = root_poa->create_POA ("my_poa", poa_manager.in (), policies); // Creation of the new POA is over, so destroy the Policy_ptr's. for (CORBA::ULong i = 0; i < policies.length (); ++i) { CORBA::Policy_ptr policy = policies[i]; policy->destroy (); } if (parse_args (argc, argv) != 0) return 1; Hello *hello_impl = 0; ACE_NEW_RETURN (hello_impl, Hello (orb.in (), Test::Hello::_nil ()), 1); PortableServer::ServantBase_var owner (hello_impl); PortableServer::ObjectId_var server_id = PortableServer::string_to_ObjectId ("server_id"); my_poa->activate_object_with_id (server_id.in (), hello_impl); CORBA::Object_var hello = my_poa->id_to_reference (server_id.in ()); CORBA::String_var ior = orb->object_to_string (hello.in ()); FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); // Get a ref to the IORManipulation object CORBA::Object_var IORM = orb->resolve_initial_references (TAO_OBJID_IORMANIPULATION, 0); // Narrow iorm = TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in()); CORBA::Object_var server = orb->string_to_object (ior.in ()); CORBA::Object_var iogr = make_iogr ("Domain_1", 1, 1, server.in ()); CORBA::String_var iorgr_string = orb->object_to_string (iogr.in ()); // Output the IOR to the <iogr_output_file> output_file = ACE_OS::fopen (iogr_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", iogr_output_file), 1); ACE_OS::fprintf (output_file, "%s", iorgr_string.in ()); ACE_OS::fclose (output_file); poa_manager->activate (); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); 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[]) { ACE_Auto_Ptr< sig_i > sig_impl; int status = 0; try { Supplier_Client client; status = client.init (argc, argv); if (status == 0) { CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 0); CORBA::ORB_ptr orb = client.orb (); sig_impl.reset( new sig_i( orb ) ); sig_var sig = sig_impl->_this (); CORBA::String_var ior = orb->object_to_string (sig.in ()); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file %s for " "writing IOR: %C", ior_output_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } CosNotifyChannelAdmin::SupplierAdmin_var admin = create_supplieradmin (ec.in ()); if (!CORBA::is_nil (admin.in ())) { create_suppliers(admin.in (), client.root_poa ()); sig_impl->wait_for_startup(); ACE_DEBUG((LM_DEBUG, " 1 supplier sending %d events...\n", (max_events*amount))); for (int i = 0; i < max_events; ++i) { SendEvents (i); } ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", (max_events*amount))); sig_impl->wait_for_completion(); ACE_OS::unlink (ior_output_file); ec->destroy(); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: Supplier exception: "); status = 1; } return status; }
int ACE_SOCK_Dgram_Bcast::mk_broadcast (const ACE_TCHAR *host_name) { ACE_TRACE ("ACE_SOCK_Dgram_Bcast::mk_broadcast"); int one = 1; if (ACE_OS::setsockopt (this->get_handle (), SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof one) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: setsockopt failed"), -1); #if !defined (ACE_WIN32) && !defined(__INTERIX) ACE_HANDLE s = this->get_handle (); char buf[BUFSIZ]; struct ifconf ifc; ifc.ifc_len = sizeof buf; ifc.ifc_buf = buf; // Get interface structure and initialize the addresses using UNIX // techniques. if (ACE_OS::ioctl (s, SIOCGIFCONF, (char *) &ifc) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface configuration)"), ACE_INVALID_HANDLE); struct ifreq *ifr = ifc.ifc_req; struct sockaddr_in host_addr; // Get host ip address if (host_name) { hostent *hp = ACE_OS::gethostbyname (ACE_TEXT_ALWAYS_CHAR (host_name)); if (hp == 0) return -1; else #if defined(_UNICOS) { ACE_UINT64 haddr; // a place to put the address char * haddrp = (char *) &haddr; // convert to char pointer ACE_OS::memcpy(haddrp,(char *) hp->h_addr,hp->h_length); host_addr.sin_addr.s_addr = haddr; } #else /* ! _UNICOS */ ACE_OS::memcpy ((char *) &host_addr.sin_addr.s_addr, (char *) hp->h_addr, hp->h_length); #endif /* ! _UNICOS */ } #if !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_VXWORKS) && !defined(__APPLE__) for (int n = ifc.ifc_len / sizeof (struct ifreq) ; n > 0; n--, ifr++) #else /* There are addresses longer than sizeof (struct sockaddr) eg. IPv6 or QNX::links. In this case address does not fit into struct ifreq. The code below could be applied everywhere, but not every system provides sockaddr.sa_len field. */ for (int nbytes = ifc.ifc_len; nbytes >= (int) sizeof (struct ifreq) && ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? (nbytes >= (int) sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len) : 1); ((ifr->ifr_addr.sa_len > sizeof (struct sockaddr)) ? (nbytes -= sizeof (ifr->ifr_name) + ifr->ifr_addr.sa_len, ifr = (struct ifreq *) ((caddr_t) &ifr->ifr_addr + ifr->ifr_addr.sa_len)) : (nbytes -= sizeof (struct ifreq), ifr++))) #endif /* !defined(AIX) && !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_VXWORKS) && !defined(__APPLE__) */ { #if defined (__QNX__) || defined (ACE_VXWORKS) // Silently skip link interfaces if (ifr->ifr_addr.sa_family == AF_LINK) continue; #endif /* __QNX__ */ // Compare host ip address with interface ip address. if (host_name) { struct sockaddr_in if_addr; ACE_OS::memcpy (&if_addr, &ifr->ifr_addr, sizeof if_addr); if (host_addr.sin_addr.s_addr != if_addr.sin_addr.s_addr) continue; } if (ifr->ifr_addr.sa_family != AF_INET) { // Note that some systems seem to generate 0 (AF_UNDEF) for // the sa_family, even when there are no errors! Thus, we // only print an error if this is not the case, or if we're // in "debugging" mode. if (ifr->ifr_addr.sa_family != 0 || ACE::debug ()) ACE_DEBUG ((LM_DEBUG, "warning %p: sa_family: %d\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: Not AF_INET", ifr->ifr_addr.sa_family)); continue; } struct ifreq flags = *ifr; struct ifreq if_req = *ifr; if (ACE_OS::ioctl (s, SIOCGIFFLAGS, (char *) &flags) == -1) { ACE_ERROR ((LM_ERROR, "%p [%s]\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get interface flags)", flags.ifr_name)); continue; } if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_UP) == 0) { ACE_ERROR ((LM_ERROR, "%p [%s]\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: Network interface is not up", flags.ifr_name)); continue; } if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_LOOPBACK)) continue; if (ACE_BIT_ENABLED (flags.ifr_flags, IFF_BROADCAST)) { if (ACE_OS::ioctl (s, SIOCGIFBRDADDR, (char *) &if_req) == -1) ACE_ERROR ((LM_ERROR, "%p [%s]\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: ioctl (get broadaddr)", flags.ifr_name)); else { ACE_INET_Addr addr (reinterpret_cast <sockaddr_in *> (&if_req.ifr_broadaddr), sizeof if_req.ifr_broadaddr); ACE_NEW_RETURN (this->if_list_, ACE_Bcast_Node (addr, this->if_list_), -1); } } else { if (host_name != 0) ACE_ERROR ((LM_ERROR, "%p [%s]\n", "ACE_SOCK_Dgram_Bcast::mk_broadcast: Broadcast is not enable for this interface.", flags.ifr_name)); } } #else ACE_UNUSED_ARG (host_name); ACE_INET_Addr addr (u_short (0), ACE_UINT32 (INADDR_BROADCAST)); ACE_NEW_RETURN (this->if_list_, ACE_Bcast_Node (addr, this->if_list_), -1); #endif /* !ACE_WIN32 && !__INTERIX */ if (this->if_list_ == 0) { errno = ENXIO; return -1; } else return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the EC Factory so we can customize the EC TAO_EC_Default_Factory::init_svcs (); // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); const ACE_TCHAR *ecname = ACE_TEXT ("EventService"); const ACE_TCHAR *address = ACE_TEXT ("localhost"); const ACE_TCHAR *iorfile = 0; u_short port = 12345; u_short listenport = 12345; int mcast = 1; for (int i = 0; argv[i] != 0; i++) { if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-ecname")) == 0) { if (argv[i+1] != 0) ecname = argv[++i]; else ACE_ERROR_RETURN ((LM_ERROR, "Missing Event channel name\n"),0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-address")) == 0) { if (argv[i+1] != 0) address = argv[++i]; else ACE_ERROR_RETURN ((LM_ERROR, "Missing address\n"),0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-port")) == 0) { if (argv[i+1] != 0) port = ACE_OS::atoi(argv[++i]); else ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"),0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-listenport")) == 0) { if (argv[i+1] != 0) listenport = ACE_OS::atoi(argv[++i]); else ACE_ERROR_RETURN ((LM_ERROR, "Missing port\n"), 0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-iorfile")) == 0) { if (argv[i+1] != 0) iorfile = argv[++i]; else ACE_ERROR_RETURN ((LM_ERROR, "Missing ior file\n"), 0); } else if (ACE_OS::strcasecmp(argv[i], ACE_TEXT ("-udp")) == 0) mcast = 0; } // Get the POA CORBA::Object_var tmpobj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (tmpobj.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Create a local event channel and register it TAO_EC_Event_Channel_Attributes attributes (poa.in (), poa.in ()); TAO_EC_Event_Channel ec_impl (attributes); ec_impl.activate (); PortableServer::ObjectId_var oid = poa->activate_object(&ec_impl); tmpobj = poa->id_to_reference(oid.in()); RtecEventChannelAdmin::EventChannel_var ec = RtecEventChannelAdmin::EventChannel::_narrow(tmpobj.in()); // Find the Naming Service. tmpobj = orb->resolve_initial_references("NameService"); CosNaming::NamingContextExt_var root_context = CosNaming::NamingContextExt::_narrow(tmpobj.in()); // Bind the Event Channel using Naming Services CosNaming::Name_var name = root_context->to_name (ACE_TEXT_ALWAYS_CHAR (ecname)); root_context->rebind(name.in(), ec.in()); // Get a proxy push consumer from the EventChannel. RtecEventChannelAdmin::SupplierAdmin_var admin = ec->for_suppliers(); RtecEventChannelAdmin::ProxyPushConsumer_var consumer = admin->obtain_push_consumer(); // Instantiate an EchoEventSupplier_i servant. EchoEventSupplier_i servant(orb.in()); // Register it with the RootPOA. oid = poa->activate_object(&servant); tmpobj = poa->id_to_reference(oid.in()); RtecEventComm::PushSupplier_var supplier = RtecEventComm::PushSupplier::_narrow(tmpobj.in()); // Connect to the EC. ACE_SupplierQOS_Factory qos; qos.insert (MY_SOURCE_ID, MY_EVENT_TYPE, 0, 1); consumer->connect_push_supplier (supplier.in (), qos.get_SupplierQOS ()); // Initialize the address server with the desired address. This will // be used by the sender object and the multicast receiver only if // one is not otherwise available via the naming service. ACE_INET_Addr send_addr (port, address); SimpleAddressServer addr_srv_impl (send_addr); // Create an instance of the addr server for local use PortableServer::ObjectId_var addr_srv_oid = poa->activate_object(&addr_srv_impl); tmpobj = poa->id_to_reference(addr_srv_oid.in()); RtecUDPAdmin::AddrServer_var addr_srv = RtecUDPAdmin::AddrServer::_narrow(tmpobj.in()); // Create and initialize the sender object PortableServer::Servant_var<TAO_ECG_UDP_Sender> sender = TAO_ECG_UDP_Sender::create(); TAO_ECG_UDP_Out_Endpoint endpoint; // need to be explicit about the address type when built with // IPv6 support, otherwise SOCK_DGram::open defaults to ipv6 when // given a sap_any address. This causes trouble on at least solaris // and windows, or at most on not-linux. if (endpoint.dgram ().open (ACE_Addr::sap_any, send_addr.get_type()) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot open send endpoint\n"), 1); } // TAO_ECG_UDP_Sender::init() takes a TAO_ECG_Refcounted_Endpoint. // If we don't clone our endpoint and pass &endpoint, the sender will // attempt to delete endpoint during shutdown. TAO_ECG_Refcounted_Endpoint clone (new TAO_ECG_UDP_Out_Endpoint (endpoint)); sender->init (ec.in (), addr_srv.in (), clone); // Setup the subscription and connect to the EC ACE_ConsumerQOS_Factory cons_qos_fact; cons_qos_fact.start_disjunction_group (); cons_qos_fact.insert (ACE_ES_EVENT_SOURCE_ANY, ACE_ES_EVENT_ANY, 0); RtecEventChannelAdmin::ConsumerQOS sub = cons_qos_fact.get_ConsumerQOS (); sender->connect (sub); // Create and initialize the receiver PortableServer::Servant_var<TAO_ECG_UDP_Receiver> receiver = TAO_ECG_UDP_Receiver::create(); // TAO_ECG_UDP_Receiver::init() takes a TAO_ECG_Refcounted_Endpoint. // If we don't clone our endpoint and pass &endpoint, the receiver will // attempt to delete endpoint during shutdown. TAO_ECG_Refcounted_Endpoint clone2 (new TAO_ECG_UDP_Out_Endpoint (endpoint)); receiver->init (ec.in (), clone2, addr_srv.in ()); // Setup the registration and connect to the event channel ACE_SupplierQOS_Factory supp_qos_fact; supp_qos_fact.insert (MY_SOURCE_ID, MY_EVENT_TYPE, 0, 1); RtecEventChannelAdmin::SupplierQOS pub = supp_qos_fact.get_SupplierQOS (); receiver->connect (pub); // Create the appropriate event handler and register it with the reactor auto_ptr<ACE_Event_Handler> eh; if (mcast) { auto_ptr<TAO_ECG_Mcast_EH> mcast_eh(new TAO_ECG_Mcast_EH (receiver.in())); mcast_eh->reactor (orb->orb_core ()->reactor ()); mcast_eh->open (ec.in()); ACE_auto_ptr_reset(eh,mcast_eh.release()); //eh.reset(mcast_eh.release()); } else { auto_ptr<TAO_ECG_UDP_EH> udp_eh (new TAO_ECG_UDP_EH (receiver.in())); udp_eh->reactor (orb->orb_core ()->reactor ()); ACE_INET_Addr local_addr (listenport); if (udp_eh->open (local_addr) == -1) ACE_ERROR ((LM_ERROR,"Cannot open EH\n")); ACE_auto_ptr_reset(eh,udp_eh.release()); //eh.reset(udp_eh.release()); } // Create an event (just a string in this case). // Create an event set for one event RtecEventComm::EventSet event (1); event.length (1); // Initialize event header. event[0].header.source = MY_SOURCE_ID; event[0].header.ttl = 1; event[0].header.type = MY_EVENT_TYPE; #if !defined (TAO_LACKS_EVENT_CHANNEL_ANY) // Initialize data fields in event. const CORBA::String_var eventData = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (ecname)); event[0].data.any_value <<= eventData; #else // Use the octet sequence payload instead char *tmpstr = const_cast<char *>(ACE_TEXT_ALWAYS_CHAR (ecname)); size_t len = ACE_OS::strlen(tmpstr) +1; event[0].data.payload.replace ( len, len, reinterpret_cast<CORBA::Octet *> (tmpstr)); #endif /* !TAO_LACKS_EVENT_CHANNEL_ANY */ if (iorfile != 0) { CORBA::String_var str = orb->object_to_string( ec.in() ); std::ofstream iorFile( ACE_TEXT_ALWAYS_CHAR(iorfile) ); iorFile << str.in() << std::endl; iorFile.close(); } ACE_DEBUG ((LM_DEBUG, "Starting main loop\n")); const int EVENT_DELAY_MS = 1000; while (1) { consumer->push (event); ACE_Time_Value tv(0, 1000 * EVENT_DELAY_MS); orb->run(tv); } orb->destroy(); return 0; } catch (CORBA::Exception& exc) { ACE_ERROR ((LM_ERROR, "Caught CORBA::Exception\n%C (%C)\n", exc._name (), exc._rep_id () )); } return 1; }
int be_visitor_interface_any_op_ch::visit_interface (be_interface *node) { if (node->cli_hdr_any_op_gen () || node->imported () || (node->is_local () && !be_global->gen_local_iface_anyops ())) { return 0; } TAO_OutStream *os = this->ctx_->stream (); const char *macro = this->ctx_->export_macro (); *os << be_nl_2; *os << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__; *os << be_nl_2; be_module *module = 0; if (node->is_nested ()) { AST_Decl *d = node; AST_Decl::NodeType nt = d->node_type (); while (nt != AST_Decl::NT_root) { if (nt == AST_Decl::NT_module) { module = be_module::narrow_from_decl (d); break; } else { d = ScopeAsDecl (d->defined_in ()); nt = d->node_type (); } } if (module != 0) { // Some compilers handle "any" operators in a namespace // corresponding to their module, others do not. *os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n"; be_util::gen_nested_namespace_begin (os, module); // emit nested variation of any operators *os << macro << " void" << " operator<<= ( ::CORBA::Any &, " << node->local_name () << "_ptr); // copying" << be_nl; *os << macro << " void" << " operator<<= ( ::CORBA::Any &, " << node->local_name () << "_ptr *); // non-copying" << be_nl; *os << macro << " ::CORBA::Boolean" << " operator>>= (const ::CORBA::Any &, " << node->local_name () << "_ptr &);"; be_util::gen_nested_namespace_end (os, module); // Emit #else. *os << be_nl_2 << "#else\n\n"; } } *os << be_global->core_versioning_begin () << be_nl; *os << macro << " void operator<<= (::CORBA::Any &, " << node->name () << "_ptr); // copying" << be_nl; *os << macro << " void operator<<= (::CORBA::Any &, " << node->name () << "_ptr *); // non-copying" << be_nl; *os << macro << " ::CORBA::Boolean operator>>= (const ::CORBA::Any &, " << node->name () << "_ptr &);"; *os << be_global->core_versioning_end () << be_nl; if (module != 0) { *os << "\n\n#endif"; } // All we have to do is to visit the scope and generate code. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_interface_any_op_ch::") ACE_TEXT ("visit_interface - ") ACE_TEXT ("codegen for scope failed\n")), -1); } node->cli_hdr_any_op_gen (1); return 0; }
int MCT_Task::open (void *) { MCT_Event_Handler *handler = 0; ACE_INET_Addr addr = this->config_.group_start (); int groups = this->config_.groups (); for (int i = 0; i < groups; ++i) { ACE_NEW_RETURN (handler, MCT_Event_Handler (this->config_.options ()), -1); // We subscribe to all groups for the first one and one each for // all the others. if (i == 0) { // go ahead and hide the other one since we want our own. ACE_INET_Addr addr = this->config_.group_start (); for (int j = 0; j < groups; ++j) { // If OPT_BINDADDR_YES is set, this will fail after the first // join, so just break and keep on going, otherwise it's a // real error. if (j > 0 && ACE_BIT_ENABLED (ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES, this->config_.options ())) break; if (handler->join (addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("MCT_Task::open - join error\n")), -1); advance_addr (addr); } } else { if (handler->join (addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("MCT_Task::open - join error\n")), -1); } advance_addr (addr); // This test needs loopback because we're both sending and receiving. // Loopback is usually the default, but be sure. if (-1 == handler->loopback (true)) ACE_ERROR ((LM_WARNING, ACE_TEXT ("%p\n"), ACE_TEXT ("MCT_Task::open - enable loopback"))); if (this->reactor ()->register_handler (handler, READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("MCT_Task::open - cannot register ") ACE_TEXT ("handler\n")), -1); } if (this->activate (THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("MCT_TASK:open - activate failed")), -1); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { #if TAO_HAS_INTERCEPTORS == 1 PortableInterceptor::ORBInitializer_ptr orb_initializer = PortableInterceptor::ORBInitializer::_nil (); ACE_NEW_RETURN (orb_initializer, Server_IORInterceptor_ORBInitializer, -1); // No CORBA exceptions yet! PortableInterceptor::ORBInitializer_var orb_initializer_var = orb_initializer; PortableInterceptor::register_orb_initializer (orb_initializer_var.in ()); #endif /* TAO_HAS_INTERCEPTORS == 1 */ // The usual initialization stuff // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "server_sum_orb"); if (parse_args (argc, argv) != 0) return -1; // Resolve reference to RootPOA CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); // Narrow it down correctly. PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in ()); // Check for nil references if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, "Unable to obtain RootPOA reference.\n"), -1); // Get poa_manager reference PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); // Activate it. poa_manager->activate (); // initialize the sum_server sum_server_i sum_server_impl; // Activate obj = sum_server_impl._this (); // Narrow it down. ORT::sum_server_var sum_server = ORT::sum_server::_narrow (obj.in ()); // Check for nil reference if (CORBA::is_nil (sum_server.in ())) ACE_ERROR_RETURN ((LM_ERROR, "Unable to obtain reference to ORT::sum_server " "object.\n"), -1); // Convert the object reference to a string format. CORBA::String_var ior = orb->object_to_string (sum_server.in ()); // If the ior_output_file exists, output the IOR to it. if (ior_output_file != 0) { FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing " "IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } orb->run (); ACE_DEBUG ((LM_INFO, "Successful.\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("ORT example server:"); return -1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int status = 0; try { Consumer_Client client; status = client.init (argc, argv); if (status == 0) { // If we are filtering, we will get half as many as originally // expected if (filter) { expected /= 2; } CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); if (CORBA::is_nil (sig.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil\n", ior), 1); } CosNotifyChannelAdmin::ConsumerAdmin_var admin = create_consumeradmin (ec.in ()); if (!CORBA::is_nil (admin.in ())) { create_consumers(admin.in (), &client); // Tell the supplier to go sig->go (); client.ORB_run(); ACE_DEBUG((LM_DEBUG, "Consumer done.\n")); sig->done (); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: Consumer exception: "); status = 1; } return status; }
int Consumer_Handler::handle_output (ACE_HANDLE) { ACE_Message_Block *event = 0; ACE_DEBUG ((LM_DEBUG, ACE_TEXT("(%t) Receiver signalled 'resume transmission' %d\n"), this->get_handle ())); // WIN32 Notes: When the receiver blocked, we started adding to the // consumer handler's message Q. At this time, we registered a // callback with the reactor to tell us when the TCP layer signalled // that we could continue to send messages to the consumer. However, // Winsock only sends this notification ONCE, so we have to assume // at the application level, that we can continue to send until we // get any subsequent blocking signals from the receiver's buffer. #if defined (ACE_WIN32) // Win32 Winsock doesn't trigger multiple "You can write now" // signals, so we have to assume that we can continue to write until // we get another EWOULDBLOCK. // We cancel the wakeup callback we set earlier. if (ACE_Reactor::instance ()->cancel_wakeup (this, ACE_Event_Handler::WRITE_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("Error in ACE_Reactor::cancel_wakeup()")), -1); // The list had better not be empty, otherwise there's a bug! while (this->msg_queue ()->dequeue_head (event, (ACE_Time_Value *) &ACE_Time_Value::zero) != -1) { switch (this->nonblk_put (event)) { case -1: // Error sending message to consumer. { // We are responsible for releasing an ACE_Message_Block if // failures occur. event->release (); ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("transmission failure"))); break; } case 0: // Partial Send - we got flow controlled by the receiver { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%D Partial Send due to flow control") ACE_TEXT ("- scheduling new wakeup with reactor\n"))); // Re-schedule a wakeup call from the reactor when the // flow control conditions abate. if (ACE_Reactor::instance ()->schedule_wakeup (this, ACE_Event_Handler::WRITE_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("Error in ACE_Reactor::schedule_wakeup()")), -1); // Didn't write everything this time, come back later... return 0; } default: // Sent the whole thing { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Sent message from message Q, Q size = %d\n"), this->msg_queue()->message_count ())); break; } } } // If we drop out of the while loop, then the message Q should be // empty...or there's a problem in the dequeue_head() call...but // thats another story. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%D Sent all messages from consumers message Q\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) queueing deactivated on handle %d to routing id %d\n"), this->get_handle (), this->connection_id ())); #else /* !defined (ACE_WIN32) */ // The list had better not be empty, otherwise there's a bug! if (this->msg_queue ()->dequeue_head (event, (ACE_Time_Value *) &ACE_Time_Value::zero) != -1) { switch (this->nonblk_put (event)) { case 0: // Partial send. ACE_ASSERT (errno == EWOULDBLOCK); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%D Partial Send\n"))); // Didn't write everything this time, come back later... break; case -1: // We are responsible for releasing an ACE_Message_Block if // failures occur. event->release (); ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("transmission failure"))); /* FALLTHROUGH */ default: // Sent the whole thing. // If we succeed in writing the entire event (or we did not // fail due to EWOULDBLOCK) then check if there are more // events on the Message_Queue. If there aren't, tell the // ACE_Reactor not to notify us anymore (at least until // there are new events queued up). ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("QQQ::Sent Message from consumer's Q\n"))); if (this->msg_queue ()->is_empty ()) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) queueing deactivated on handle %d to routing id %d\n"), this->get_handle (), this->connection_id ())); if (ACE_Reactor::instance ()->cancel_wakeup (this, ACE_Event_Handler::WRITE_MASK) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("cancel_wakeup"))); } } } else ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) %p\n"), ACE_TEXT ("dequeue_head - handle_output called by reactor but nothing in Q"))); #endif /* ACE_WIN32 */ return 0; }
int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1); }
pid_t ACE_Process_Manager::wait (pid_t pid, const ACE_Time_Value &timeout, ACE_exitcode *status) { ACE_TRACE ("ACE_Process_Manager::wait"); ACE_exitcode local_stat = 0; if (status == 0) status = &local_stat; *status = 0; ssize_t idx = -1; ACE_Process *proc = 0; ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); if (pid != 0) { idx = this->find_proc (pid); if (idx == -1) return ACE_INVALID_PID; else proc = process_table_[idx].process_; } if (proc != 0) pid = proc->wait (timeout, status); else { // Wait for any Process spawned by this Process_Manager. #if defined (ACE_WIN32) HANDLE *handles; ACE_NEW_RETURN (handles, HANDLE[this->current_count_], ACE_INVALID_PID); for (size_t i = 0; i < this->current_count_; ++i) handles[i] = process_table_[i].process_->gethandle (); DWORD handle_count = ACE_static_cast (DWORD, this->current_count_); DWORD result = ::WaitForMultipleObjects (handle_count, handles, FALSE, timeout == ACE_Time_Value::max_time ? INFINITE : timeout.msec ()); if (result == WAIT_FAILED) pid = ACE_INVALID_PID; else if (result == WAIT_TIMEOUT) pid = 0; else { // Green Hills produces a warning that result >= WAIT_OBJECT_0 is // a pointless comparison because WAIT_OBJECT_0 is zero and DWORD is // unsigned long, so this test is skipped for Green Hills. // Same for mingw. # if defined (ghs) || defined (__MINGW32__) ACE_ASSERT (result < WAIT_OBJECT_0 + this->current_count_); # else ACE_ASSERT (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + this->current_count_); # endif idx = this->find_proc (handles[result - WAIT_OBJECT_0]); if (idx != -1) { pid = process_table_[idx].process_->getpid (); result = ::GetExitCodeProcess (handles[result - WAIT_OBJECT_0], status); if (result == 0) { // <GetExitCodeProcess> failed! this->remove_proc (idx); pid = ACE_INVALID_PID; } } else { // uh oh...handle removed from process_table_, even though // we're holding a lock! delete [] handles; ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("Process removed") ACE_LIB_TEXT (" -- somebody's ignoring the lock!\n")), -1); } } delete [] handles; #else /* !defined(ACE_WIN32) */ if (timeout == ACE_Time_Value::max_time) { pid = ACE_OS::waitpid (-1, status, 0); } else if (timeout == ACE_Time_Value::zero) { pid = ACE_OS::waitpid (-1, status, WNOHANG); } else { // Force generation of SIGCHLD, even though we don't want to // catch it - just need it to interrupt the sleep below. // If this object has a reactor set, assume it was given at // open(), and there's already a SIGCHLD action set, so no // action is needed here. ACE_Sig_Action old_action; if (this->reactor () == 0) { ACE_Sig_Action do_sigchld ((ACE_SignalHandler)sigchld_nop); do_sigchld.register_action (SIGCHLD, &old_action); } ACE_Time_Value tmo (timeout); // Need one we can change for (ACE_Countdown_Time time_left (&tmo); ; time_left.update ()) { pid = ACE_OS::waitpid (-1, status, WNOHANG); if (pid > 0 || pid == ACE_INVALID_PID) break; // Got a child or an error - all done // pid 0, nothing is ready yet, so wait. // Do a sleep (only this thread sleeps) til something // happens. This relies on SIGCHLD interrupting the sleep. // If SIGCHLD isn't delivered, we'll need to do something // with sigaction to force it. if (-1 == ACE_OS::sleep (tmo) && errno == EINTR) continue; // Timed out pid = 0; break; } // Restore the previous SIGCHLD action if it was changed. if (this->reactor () == 0) { old_action.register_action (SIGCHLD); } } #endif /* !defined (ACE_WIN32) */ } if (pid != ACE_INVALID_PID && pid != 0) { if (proc == 0) { idx = this->find_proc (pid); if (idx == -1) { // oops, reaped an unmanaged process! ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%P|%t) oops, reaped unmanaged %d\n"), pid)); return pid; } else proc = process_table_[idx].process_; } else ACE_ASSERT (pid == proc->getpid ()); this->notify_proc_handler (idx, *status); this->remove_proc (idx); } return pid; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize DomainParticipantFactory DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); int error; if ((error = parse_args(argc, argv)) != 0) { return error; } // Create DomainParticipant DDS::DomainParticipant_var participant = dpf->create_participant(4, PARTICIPANT_QOS_DEFAULT, DDS::DomainParticipantListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(participant.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: create_participant() failed!\n")), -1); } // Register Type (Messenger::Message) Messenger::MessageTypeSupport_var ts = new Messenger::MessageTypeSupportImpl(); if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: register_type() failed!\n")), -1); } // Create Topic (Movie Discussion List) DDS::Topic_var topic = participant->create_topic("Movie Discussion List", ts->get_type_name(), TOPIC_QOS_DEFAULT, DDS::TopicListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(topic.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: create_topic() failed!\n")), -1); } // Create Subscriber DDS::Subscriber_var sub = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, DDS::SubscriberListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(sub.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: create_subscriber() failed!\n")), -1); } // Create DataReader DataReaderListenerImpl listener; DDS::DataReader_var reader = sub->create_datareader(topic.in(), DATAREADER_QOS_DEFAULT, &listener, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(reader.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: create_datareader() failed!\n")), -1); } // Block until Publisher completes DDS::StatusCondition_var condition = reader->get_statuscondition(); condition->set_enabled_statuses(DDS::SUBSCRIPTION_MATCHED_STATUS); DDS::WaitSet_var ws = new DDS::WaitSet; ws->attach_condition(condition); DDS::Duration_t timeout = { DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC }; DDS::ConditionSeq conditions; DDS::SubscriptionMatchedStatus matches = { 0, 0, 0, 0, 0 }; do { if (ws->wait(conditions, timeout) != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: wait() failed!\n")), -1); } if (reader->get_subscription_matched_status(matches) != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l main()") ACE_TEXT(" ERROR: get_subscription_matched_status() failed!\n")), -1); } } while (matches.current_count > 0); ws->detach_condition(condition); // Clean-up! participant->delete_contained_entities(); dpf->delete_participant(participant.in()); TheServiceParticipant->shutdown(); } catch (const CORBA::Exception& e) { e._tao_print_exception("Exception caught in main():"); return -1; } return 0; }
int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Priority_Task_Test")); if (argc <= 1) // Disable LM_DEBUG messages. ACE_Log_Msg::instance ()->priority_mask (ACE_Log_Msg::instance ()->priority_mask () &~ LM_DEBUG); else if (argc == 2) { if (ACE_OS::strcmp (argv[1], ACE_TEXT ("-d")) != 0) ACE_ERROR_RETURN ((LM_ERROR, usage, argv [0]), -1); // else -d option: don't disable LM_DEBUG messages } else ACE_ERROR_RETURN ((LM_ERROR, usage, argv [0]), -1); int status = 0; #if defined (ACE_HAS_THREADS) Priority_Task tasks[ACE_MAX_ITERATIONS]; size_t i; // Spawn off ACE_MAX_ITERATIONS of tasks, passing each one their // iteration number as their priority. // NOTE: on Solaris, for example, this requests the min FIFO // priority. But, this test doesn't use the Realtime scheduling // class. The FIFO priorities are used because they're all // nonnegative. ACE_Sched_Priority_Iterator priority (ACE_SCHED_FIFO, ACE_SCOPE_THREAD); for (i = 0; i < ACE_MAX_ITERATIONS; i++) { int p = priority.priority (); if (tasks[i].open ((void *) &p) == -1) break; // Out of enclosing loop. // If there are more priorities get the next one... if (priority.more ()) priority.next (); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) %d tasks spawned, wait for them to exit . . .\n"), ACE_MAX_ITERATIONS)); // Wait for all tasks to exit. ACE_Thread_Manager::instance ()->wait (); for (i = 0; i < ACE_MAX_ITERATIONS; i++) if (!tasks[i].succeeded ()) { ++status; break; } #else ACE_ERROR ((LM_DEBUG, ACE_TEXT ("threads not supported on this platform\n"))); #endif /* ACE_HAS_THREADS */ // Re-enable LM_DEBUG messages. ACE_Log_Msg::instance ()->priority_mask (ACE_Log_Msg::instance ()->priority_mask () | LM_DEBUG); ACE_END_TEST; return status; }
int ACE_TMAIN ( int argc, ACE_TCHAR* argv[] ) { try { // Initialize orb 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( _sessionService_ior ); ENW::ISessionService_var sessionService = ENW::ISessionService::_narrow (obj.in () ); if( CORBA::is_nil( sessionService.in() ) ) { ACE_ERROR_RETURN( ( LM_ERROR, "Unable to acquire 'SessionService' objref\n" ), -1 ); } ACE_DEBUG( ( LM_DEBUG, SEPARATION_LINE ) ); for( int i = 0; i < _loop; ++i ) { switch( _testcase ) { case TESTCASE_ACQUIRE_RELEASE_SESSION: { ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) Executing testcase acquire release session...[running]\n" ) ); ENW::TSession_var session = sessionService->acquireSession( _ident ); //CORBA::Long ident = session->getIdent(); sessionService->releaseSession( _ident, session.in () ); ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) Executing testcase acquire release session...[ready]\n" ) ); } break; case TESTCASE_CREATE_DESTROY_SESSION: { ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) Executing testcase create destroy session...[running]\n" ) ); ENW::TSession_var session = sessionService->createSession(); CORBA::Long ident = session->getIdent(); ACE_DEBUG(( LM_DEBUG, "(%P|%t@%T) Ident: %d\n", ident ) ); if( !sessionService->destroySession( session.in () ) ) { ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) Executing testcase create destroy session...[ERROR]\n" ) ); } ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) Executing testcase create destroy session...[ready]\n" ) ); } break; default: ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) Testcase is undefined!\n" ) ); break; } } orb->destroy( ); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Who is the culprit\n"); cerr << "Uncaught CORBA exception" << endl; return 1; } return 0; }
int Service_Config_ORB_DLL::init (int argc, ACE_TCHAR *argv[]) { ACE_Arg_Shifter arg_shifter (argc, argv); while (arg_shifter.is_anything_left ()) { if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-c")) == 0) { this->is_server_ = 0; arg_shifter.consume_arg(); } else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-s")) == 0) { this->is_server_ = 1; arg_shifter.consume_arg(); } else arg_shifter.ignore_arg(); } if (this->is_server_ < 0) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) You must specify -c(lient) or -s(erver) argument. Aborting."), -1); ACE_TCHAR **temp_argv = new ACE_TCHAR*[argc+1]; for (int i = 0; i < argc; i++) { temp_argv[i] = new ACE_TCHAR[ACE_OS::strlen(argv[i])+1]; ACE_OS::strcpy (temp_argv[i],argv[i]); } temp_argv[argc] = 0; ACE_ARGV* tmp = 0; ACE_NEW_RETURN (tmp, ACE_ARGV (temp_argv), -1); this->argv_.reset (tmp); for (int i = 0; i < argc; i++) delete [] temp_argv[i]; delete [] temp_argv; Abstract_Worker* worker = 0; if (this->is_server_) { ACE_NEW_RETURN (worker, Server_Worker, -1); } else { ACE_NEW_RETURN (worker, Client_Worker, -1); } this->worker_.reset (worker); #if defined (ACE_HAS_THREADS) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) About to activate %s, argv[%d]=\'%s\' ...\n"), this->worker_->kind (), this->argv_->argc (), this->argv_->buf ())); // Become an Active Object if more than one argument passed. // Two arguments indicate two "test objects" to be dynamically // loaded. return this->activate (); #else ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) Threading support is required for this test. Aborting.")), -1); #endif /* ACE_HAS_THREADS */ }
int ACE_TMAIN(int argc, ACE_TCHAR** argv) { parse_args(argc, argv); ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) -> SUBSCRIBER STARTED\n"))); ::CORBA::Long sec = deadline_msec / 1000; ::CORBA::ULong remainder_msec = (deadline_msec - 1000*sec); ::CORBA::ULong nanosec = remainder_msec * 1000000; DDS::Duration_t const DEADLINE_PERIOD = { sec, nanosec }; bool deadline_used = DEADLINE_PERIOD.sec > 0 || DEADLINE_PERIOD.nanosec > 0; try { DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); SubscriberListenerImpl * subscriberListener = new SubscriberListenerImpl(received_samples, missed_samples); DDS::SubscriberListener_var subscriberListener_var = subscriberListener; // Create Participant DDS::DomainParticipant_var participant = dpf->create_participant(42, PARTICIPANT_QOS_DEFAULT, DDS::DomainParticipantListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(participant.in())) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: main()") ACE_TEXT(" create_participant failed!\n")), 1); ACE_Time_Value delay_between_cycles(0, delay_between_cycles_msec * 1000); bool expected_samples_received = false; int i = 0; do { ++i; ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) -> Subscriber cycle %d\n"), i)); // Create Subscriber DDS::Subscriber_var subscriber = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, subscriberListener, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(subscriber.in())) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: main()") ACE_TEXT(" create_subscriber failed!\n")), 2); // Register Type (FooType) FooTypeSupport_var ts = new FooTypeSupportImpl; if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: main()") ACE_TEXT(" register_type failed!\n")), 5); // Create Topic (FooTopic) DDS::Topic_var topic = participant->create_topic("FooTopic", ts->get_type_name(), TOPIC_QOS_DEFAULT, DDS::TopicListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); DDS::TopicDescription_ptr topic_used = topic.in(); DDS::ContentFilteredTopic_ptr cft = 0; if (use_cft) { // Topic name must be unique. ACE_CString topic_name = "FooTopic-Filtered-" + toStr(i); cft = participant->create_contentfilteredtopic(topic_name.c_str(), topic, "key > 0", DDS::StringSeq()); if (CORBA::is_nil(cft)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: main()") ACE_TEXT(" create_contentfilteredtopic failed!\n")), 8); topic_used = cft; } if (CORBA::is_nil(topic.in())) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: main()") ACE_TEXT(" create_topic failed!\n")), 6); // Create DataReader DDS::DataReaderQos reader_qos; subscriber->get_default_datareader_qos(reader_qos); reader_qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS; if (deadline_used) { reader_qos.deadline.period.sec = DEADLINE_PERIOD.sec; reader_qos.deadline.period.nanosec = DEADLINE_PERIOD.nanosec; } DDS::DataReader_var reader = subscriber->create_datareader(topic_used, reader_qos, DDS::DataReaderListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(reader.in())) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("%N:%l: main()") ACE_TEXT(" create_datareader failed!\n")), 7); ACE_Time_Value sample_count_sleep(0, sample_count_sleep_msec * 1000); std::size_t sample_count; std::size_t sample_count_start = subscriberListener->samples_processed(); do { ACE_OS::sleep(sample_count_sleep); sample_count = subscriberListener->samples_processed(); expected_samples_received = sample_count >= expected_samples; // ACE_DEBUG((LM_DEBUG, "(%P|%t) sample_count = %d\n", sample_count)); } while (!expected_samples_received && (sample_count - sample_count_start) < samples_per_cycle); subscriber->delete_datareader(reader.in()); if (use_cft) CORBA::release(cft); participant->delete_subscriber(subscriber.in()); ACE_OS::sleep(delay_between_cycles); } while (!expected_samples_received); participant->delete_contained_entities(); dpf->delete_participant(participant.in()); TheServiceParticipant->shutdown(); ACE_DEBUG ((LM_INFO, ACE_TEXT("INFO: %d samples received\n"), subscriberListener->received_samples())); if (deadline_used) ACE_DEBUG ((LM_INFO, ACE_TEXT("INFO: deadline missed %d times\n"), subscriberListener->missed_samples())); } catch (const CORBA::Exception& e) { e._tao_print_exception("caught in main()"); return 9; } ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) <- SUBSCRIBER FINISHED\n"))); return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); int parse_args_result = parse_args (argc, argv); if (parse_args_result != 0) return parse_args_result; // Make sure we can support multiple priorities that are required // for this test. if (!check_supported_priorities (orb.in ())) return 2; // Thread Manager for managing task. ACE_Thread_Manager thread_manager; // Create task. Task task (thread_manager, orb.in ()); // Task activation flags. long flags = THR_NEW_LWP | THR_JOINABLE | orb->orb_core ()->orb_params ()->thread_creation_flags (); // Activate task. int result = task.activate (flags); if (result == -1) { if (errno == EPERM) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot create thread with scheduling policy %C\n" "because the user does not have the appropriate privileges, terminating program....\n" "Check svc.conf options and/or run as root\n", sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())), 2); } else // Unexpected error. ACE_ASSERT (0); } // Wait for task to exit. result = thread_manager.wait (); ACE_ASSERT (result != -1); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Error!"); return -1; } return 0; }
int MCT_Config::open (int argc, ACE_TCHAR *argv[]) { int retval = 0; int help = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_Get_Opt getopt (argc, argv, ACE_TEXT (":?"), 1, 1); //FUZZ: enable check_for_lack_ACE_OS if (getopt.long_option (ACE_TEXT ("GroupStart"), 'g', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add GroupStart option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Groups"), 'n', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Groups option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Debug"), 'd', ACE_Get_Opt::NO_ARG) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Debug option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Role"), 'r', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Role option.\n")), 1); if (getopt.long_option (ACE_TEXT ("SDM_options"), 'm', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add Multicast_Options option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Iterations"), 'i', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add iterations option.\n")), 1); if (getopt.long_option (ACE_TEXT ("TTL"), 't', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add TTL option.\n")), 1); if (getopt.long_option (ACE_TEXT ("Wait"), 'w', ACE_Get_Opt::ARG_REQUIRED) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add wait option.\n")), 1); if (getopt.long_option (ACE_TEXT ("help"), 'h', ACE_Get_Opt::NO_ARG) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" Unable to add help option.\n")), 1); //FUZZ: disable check_for_lack_ACE_OS // Now, let's parse it... int c = 0; while ((c = getopt ()) != EOF) { //FUZZ: enable check_for_lack_ACE_OS switch (c) { case 0: // Long Option. This should never happen. retval = -1; break; case 'g': { // @todo validate all these, i.e., must be within range // 224.255.0.0 to 238.255.255.255, but we only allow the // administrative "site local" range, 239.255.0.0 to // 239.255.255.255. ACE_TCHAR *group = getopt.opt_arg (); if (this->group_start_.set (group) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Bad group address:%s\n"), group)); } } break; case 'i': this->iterations_ = ACE_OS::atoi (getopt.opt_arg ()); break; case 'n': { int n = ACE_OS::atoi (getopt.opt_arg ()); // I'm assuming 0 means unlimited, so just use whatever the // user provides. Seems to work okay on Solaris 5.8. if (IP_MAX_MEMBERSHIPS == 0) this->groups_ = n; else this->groups_ = ACE_MIN (ACE_MAX (n, MCT_MIN_GROUPS), IP_MAX_MEMBERSHIPS); break; } case 'd': this->debug_ = 1; break; case 'r': { ACE_TCHAR *c = getopt.opt_arg (); if (ACE_OS::strcasecmp (c, ACE_TEXT ("CONSUMER")) == 0) this->role_ = CONSUMER; else if (ACE_OS::strcasecmp (c, ACE_TEXT ("PRODUCER")) == 0) this->role_ = PRODUCER; else { help = 1; retval = -1; } } break; case 'm': { //@todo add back OPT_BINDADDR_NO... ACE_TCHAR *c = getopt.opt_arg (); if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_YES")) == 0) ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_NO")) == 0) ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_BINDADDR")) == 0) { ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES); ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::DEFOPT_BINDADDR); } else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ALL")) == 0) ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ONE")) == 0) ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL); else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_NULLIFACE")) == 0) { ACE_CLR_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL); ACE_SET_BITS (this->sdm_opts_, ACE_SOCK_Dgram_Mcast::DEFOPT_NULLIFACE); } else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPTS")) == 0) this->sdm_opts_ = ACE_SOCK_Dgram_Mcast::DEFOPTS; else { help = 1; retval = -1; } } break; case 't': this->ttl_ = ACE_OS::atoi (getopt.opt_arg ()); break; case 'w': this->wait_ = ACE_OS::atoi (getopt.opt_arg ()); break; case ':': // This means an option requiring an argument didn't have one. ACE_ERROR ((LM_ERROR, ACE_TEXT (" Option '%c' requires an argument but ") ACE_TEXT ("none was supplied\n"), getopt.opt_opt ())); help = 1; retval = -1; break; case '?': case 'h': default: if (ACE_OS::strcmp (argv[getopt.opt_ind () - 1], ACE_TEXT ("-?")) != 0 && getopt.opt_opt () != 'h') // Don't allow unknown options. ACE_ERROR ((LM_ERROR, ACE_TEXT (" Found an unknown option (%c) ") ACE_TEXT ("we couldn't handle.\n"), getopt.opt_opt ())); // getopt.last_option ())); //readd with "%s" when // last_option() is available. help = 1; retval = -1; break; } } if (retval == -1) { if (help) // print usage here ACE_ERROR ((LM_ERROR, ACE_TEXT ("usage: %s [options]\n") ACE_TEXT ("Options:\n") ACE_TEXT (" -g {STRING} --GroupStart={STRING} ") ACE_TEXT ("starting multicast group address\n") ACE_TEXT (" ") ACE_TEXT ("(default=239.255.0.1:16000)\n") ACE_TEXT (" -n {#} --Groups={#} ") ACE_TEXT ("number of groups (default=5)\n") ACE_TEXT (" -d --Debug ") ACE_TEXT ("debug flag (default=off)\n") ACE_TEXT (" -r {STRING} --Role={STRING} ") ACE_TEXT ("role {PRODUCER|CONSUMER|BOTH}\n") ACE_TEXT (" ") ACE_TEXT ("(default=BOTH)\n") ACE_TEXT (" -m {STRING} --SDM_options={STRING} ") ACE_TEXT ("ACE_SOCK_Dgram_Mcast ctor options\n") ACE_TEXT (" ") ACE_TEXT ("(default=DEFOPTS)\n") ACE_TEXT (" -i {#} --Iterations={#} ") ACE_TEXT ("number of iterations (default=100)\n") ACE_TEXT (" -t {#} --TTL={#} ") ACE_TEXT ("time to live (default=1)\n") ACE_TEXT (" -w {#} --Wait={#} ") ACE_TEXT ("number of seconds to wait on CONSUMER\n") ACE_TEXT (" ") ACE_TEXT ("(default=2)\n") ACE_TEXT (" -h/? --help ") ACE_TEXT ("show this message\n"), argv[0])); return -1; } return 0; }
// Recieve the HTTP Reply int ACE_Blob_Reader::receive_reply (void) { ssize_t len; char buf [MAX_HEADER_SIZE + 1]; char *buf_ptr; size_t bytes_read = 0; size_t bytes_left = this->length_; size_t offset_left = this->offset_; // Receive the first MAX_HEADER_SIZE bytes to be able to strip off the // header. Note that we assume that the header will fit into the // first MAX_HEADER_SIZE bytes of the transmitted data. if ((len = peer ().recv_n (buf, MAX_HEADER_SIZE)) >= 0) { buf[len] = '\0'; // Search for the header termination string "\r\n\r\n", or "\n\n". If // found, move past it to get to the data portion. if ((buf_ptr = ACE_OS::strstr (buf,"\r\n\r\n")) != 0) buf_ptr += 4; else if ((buf_ptr = ACE_OS::strstr (buf, "\n\n")) != 0) buf_ptr += 2; else buf_ptr = buf; // Determine number of data bytes read. This is equal to the // total bytes read minus number of header bytes. bytes_read = (buf + len) - buf_ptr; } else ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Error while reading header"), -1); // *************************************************************** // At this point, we have stripped off the header and are ready to // process data. buf_ptr points to the data // First adjust for offset. There are two cases: // (1) The first block of data encountered the offset. In this case // we simply increment the buf_ptr by offset. // (2) The first block of data did not encounter the offset. That // is, the offset needs to go past the number of data bytes already read. if (bytes_read > offset_left) { // The first case is true -- that is offset is less than the // data bytes we just read. buf_ptr += offset_left; // Determine how many data bytes are actually there. This is // basically the total number of data bytes we read minus any // offset we have. size_t data_bytes = bytes_read - offset_left; // Check for the case where the bytes read are enough to fulfill // our request (for length bytes). If this is the case, then we // don't need to do any extra recvs and can simply return with // the data. if (data_bytes >= bytes_left) { // The first block contains enough data to satisfy the // length. So copy the data into the message buffer. if (mb_->copy (buf_ptr, bytes_left) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE Blob_Reader::receiveReply():Error copying data into Message_Block"), -1); bytecount_ = length_; return 0; } // Copy over all the data bytes into our message buffer. if (mb_->copy (buf_ptr, data_bytes) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Error copying data into Message_Block" ), -1); // Adjust bytes left bytes_left -= data_bytes; // No more offset left. So set it to zero. offset_left = 0; } else { // The second case is true -- that is offset is greater than // the data bytes we just read. offset_left -= bytes_read; } // If we ad any offset left, take care of that. while (offset_left > 0) { // MAX_HEADER_SIZE in which case we should do a receive of // offset bytes into a temporary buffer. Otherwise, we should // receive MAX_HEADER_SIZE bytes into temporary buffer and // decrement offset_left. if (offset_left < (sizeof buf)) len = offset_left; else len = sizeof buf; if (peer().recv_n (buf, len) != len) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Read error" ), -1); offset_left -= len; } // ***************************************************************** // At this point we are all set to receive the actual data which the // user wants. We have made adjustments for offset and are ready to // receive the actual data. Receive the data directly into the // message buffer. len = peer().recv_n (mb_->wr_ptr (), bytes_left); if (len < 0 || static_cast<size_t> (len) != bytes_left) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ACE_Blob_Reader::receiveReply():Read error" ), -1); // Adjust the message buffer write pointer by number of bytes we // received. mb_->wr_ptr (len); // Set the byte count to number of bytes received this->bytecount_ = length_; return 0; }
int parse_args (int argc, ACE_TCHAR *argv[]) { ACE_Get_Opt get_opts (argc, argv, "b:f:hl:n:o:s:" // server options "c:e:g:hi:j:k:m:p:q:r:t:u:v:w:x:y:z:" // client options ); int c; while ((c = get_opts ()) != -1) switch (c) { case 'b': bands_file = get_opts.opt_arg (); break; case 'f': pool_priority = ACE_OS::atoi (get_opts.opt_arg ()); break; case 'l': lanes_file = get_opts.opt_arg (); break; case 'n': number_of_lanes = ACE_OS::atoi (get_opts.opt_arg ()); break; case 'o': ior_output_file = get_opts.opt_arg (); break; case 's': static_threads = ACE_OS::atoi (get_opts.opt_arg ()); break; case 'c': case 'e': case 'g': case 'i': case 'j': case 'k': case 'm': case 'p': case 'q': case 'r': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': // client options: ignored. break; case 'h': case '?': default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s\n" "\t-b <bands file> (defaults to %s)\n" "\t-f <pool priority> (defaults to %d)\n" "\t-h <help: shows options menu>\n" "\t-l <lanes file> (defaults to %s)\n" "\t-n <number of lanes> (defaults to %d)\n" "\t-o <ior file> (defaults to %s)\n" "\t-s <static threads> (defaults to %d)\n" "\n", argv [0], bands_file, default_thread_priority, lanes_file, number_of_lanes, ior_output_file, static_threads), -1); } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // Parse the command-line arguments to get the IOR parse_args (argc, argv); // If ior_input_file exists, Read the file, and get the IOR // else, it must have been specified on the command line if (ior_input_file != 0) { ACE_HANDLE input_file = ACE_OS::open (ior_input_file, 0); if (input_file == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open input file for reading IOR: %s\n", ior_input_file), -1); ACE_Read_Buffer ior_buffer (input_file); char *data = ior_buffer.read (); if (data == 0) ACE_ERROR_RETURN ((LM_ERROR, "Unable to read ior\n"), -1); ior = ACE_OS::strdup (ACE_TEXT_CHAR_TO_TCHAR(data)); ior_buffer.alloc ()->free (data); ACE_OS::close (input_file); } // Get the object reference with the IOR CORBA::Object_var object = orb->string_to_object (ior); CORBA::String_var string; // Narrow the object reference A_var a = A::_narrow (object.in ()); // Narrow the object reference intB_var b = intB::_narrow (a.in ()); // Narrow the object reference C_var c = C::_narrow (a.in ()); // Narrow the object reference D_var d = D::_narrow (c.in ()); string = a->method1 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = b->method1 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = b->method2 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = c->method1 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = c->method3 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = d->method1 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = d->method2 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = d->method3 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); string = d->method4 (); ACE_DEBUG ((LM_DEBUG, "%C\n", string.in ())); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("client"); return 1; } return 0; }
bool DAnCE_RepositoryManager_Module::parse_args (int argc, ACE_TCHAR * argv[]) { DANCE_TRACE ("DAnCE_RepositoryManager_Module::parse_args"); ACE_Get_Opt get_opts (argc - 1, argv + 1, ACE_TEXT(":hd:t:f:p:n:"), 0, 0, ACE_Get_Opt::RETURN_IN_ORDER, 1); get_opts.long_option (ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG); get_opts.long_option (ACE_TEXT("domain-nc"), 'd', ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("file"), 'f', ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("threads"), 't', ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("package-dir"), 'p', ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("name"), 'n', ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("server-address"), 's', ACE_Get_Opt::ARG_REQUIRED); #ifdef DANCE_RM_USES_JAWS get_opts.long_option (ACE_TEXT("spawn-http"), ACE_Get_Opt::NO_ARG); get_opts.long_option (ACE_TEXT("http-port"), ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("http-threads"), ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("http-threading"), ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("http-io"), ACE_Get_Opt::ARG_REQUIRED); get_opts.long_option (ACE_TEXT("http-caching"), ACE_Get_Opt::ARG_REQUIRED); #endif /* DANCE_RM_USES_JAWS */ //get_opts.long_option ("help", '?'); int c; while ( (c = get_opts ()) != -1) { switch (c) { case 'd': DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Binding to provided Domain Naming Context: '%s'\n"), get_opts.opt_arg ())); this->options_.domain_nc_ = get_opts.opt_arg (); break; case 'f': DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Output filename for IOR is %s\n"), get_opts.opt_arg ())); this->options_.ior_file_ = get_opts.opt_arg (); break; case 't': DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Number of threads is %s\n"), get_opts.opt_arg ())); this->options_.threads_ = (ACE_OS::atoi (get_opts.opt_arg ())); break; case 'p': DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Package directory is %s\n"), get_opts.opt_arg ())); this->options_.package_dir_ = get_opts.opt_arg (); break; case 'n': DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Name is %s\n"), get_opts.opt_arg ())); this->options_.name_ = get_opts.opt_arg (); break; case 's': DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Server address is %s\n"), get_opts.opt_arg ())); this->options_.server_address_ = get_opts.opt_arg (); break; case 0: if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("spawn-http")) == 0) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Found option to spawn in-process HTTP server\n"))); this->options_.spawn_http_ = true; } else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-port")) == 0) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Using %s as the spawned HTTP server port\n"), get_opts.opt_arg ())); this->options_.spawn_http_ = true; this->options_.http_port_ = get_opts.opt_arg (); } else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-threads")) == 0) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Using %s as the spawned HTTP number of threads\n"), get_opts.opt_arg ())); this->options_.spawn_http_ = true; this->options_.http_threads_ = get_opts.opt_arg (); } else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-threading")) == 0) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Using %s as the spawned HTTP server threading model\n"), get_opts.opt_arg ())); this->options_.spawn_http_ = true; this->options_.http_threading_ = get_opts.opt_arg (); } else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-io")) == 0) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Using %s as the spawned HTTP server IO strategy\n"), get_opts.opt_arg ())); this->options_.spawn_http_ = true; this->options_.http_io_ = get_opts.opt_arg (); } else if (ACE_OS::strcmp (get_opts.long_option (), ACE_TEXT("http-caching")) == 0) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Using %s as the spawned HTTP server caching strategy\n"), get_opts.opt_arg ())); this->options_.spawn_http_ = true; this->options_.http_caching_ = get_opts.opt_arg (); } else { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("ERROR: unknown long option %s\n"), get_opts.long_option ())); } break; case 'h': case '?': // Display help for use of the server. default: ACE_ERROR_RETURN ((LM_ERROR, this->usage (), argv [0], c), false); break; } } if (this->options_.server_address_ == 0) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT("Repository_Manager_Module::parse_args - ") ACE_TEXT("Must provide server address using --server-address option.\n"))); return false; } return true; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize DomainParticipantFactory DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); // Create DomainParticipant DDS::DomainParticipant_var participant = dpf->create_participant(42, PARTICIPANT_QOS_DEFAULT, DDS::DomainParticipantListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(participant.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_participant failed!\n")), -1); } // Register TypeSupport (Messenger::Message) Messenger::MessageTypeSupport_var ts = new Messenger::MessageTypeSupportImpl(); if (ts->register_type(participant.in(), "") != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" register_type failed!\n")), -1); } // Create Topic (Movie Discussion List) CORBA::String_var type_name = ts->get_type_name(); DDS::Topic_var topic = participant->create_topic("Movie Discussion List", type_name.in(), TOPIC_QOS_DEFAULT, DDS::TopicListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(topic.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_topic failed!\n")), -1); } // Create Publisher DDS::Publisher_var publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT, DDS::PublisherListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(publisher.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_publisher failed!\n")), -1); } // Create DataWriter DDS::DataWriter_var writer = publisher->create_datawriter(topic.in(), DATAWRITER_QOS_DEFAULT, DDS::DataWriterListener::_nil(), OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (CORBA::is_nil(writer.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_datawriter failed!\n")), -1); } Messenger::MessageDataWriter_var message_writer = Messenger::MessageDataWriter::_narrow(writer.in()); if (CORBA::is_nil(message_writer.in())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" _narrow failed!\n")), -1); } // Block until Subscriber is available DDS::StatusCondition_var condition = writer->get_statuscondition(); condition->set_enabled_statuses(DDS::PUBLICATION_MATCHED_STATUS); DDS::WaitSet_var ws = new DDS::WaitSet; ws->attach_condition(condition); DDS::ConditionSeq conditions; DDS::PublicationMatchedStatus matches = { 0, 0, 0, 0, 0 }; DDS::Duration_t timeout = { 30, 0 }; do { if (ws->wait(conditions, timeout) != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" wait failed!\n")), -1); } if (writer->get_publication_matched_status(matches) != ::DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" get_publication_matched_status failed!\n")), -1); } } while (matches.current_count < 1); ws->detach_condition(condition); // Write samples Messenger::Message message; message.subject_id = 99; message.from = CORBA::string_dup("Comic Book Guy"); message.subject = CORBA::string_dup("Review"); message.text = CORBA::string_dup("Worst. Movie. Ever."); message.count = 0; for (int i = 0; i < 10; i++) { DDS::ReturnCode_t error = message_writer->write(message, DDS::HANDLE_NIL); if (error != DDS::RETCODE_OK) { ACE_ERROR((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" write returned %d!\n"), error)); } } // Wait for samples to be acknowledged if (message_writer->wait_for_acknowledgments(timeout) != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" wait_for_acknowledgments failed!\n")), -1); } // Clean-up! participant->delete_contained_entities(); dpf->delete_participant(participant.in()); TheServiceParticipant->shutdown(); } catch (const CORBA::Exception& e) { e._tao_print_exception("Exception caught in main():"); return -1; } return 0; }
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 be_visitor_attribute::visit_attribute (be_attribute *node) { this->ctx_->node (node); this->ctx_->attribute (node); UTL_Scope *s = node->defined_in (); AST_Decl *d = ScopeAsDecl (s); ACE_CString op_name (this->ctx_->port_prefix ()); op_name += node->local_name ()->get_string (); Identifier *op_id = 0; ACE_NEW_RETURN (op_id, Identifier (op_name.c_str ()), -1); UTL_ScopedName *op_ln = 0; ACE_NEW_RETURN (op_ln, UTL_ScopedName (op_id, 0), -1); UTL_ScopedName *op_sn = static_cast<UTL_ScopedName *> (d->name ()->copy ()); op_sn->nconc (op_ln); // first the "get" operation be_operation get_op (node->field_type (), AST_Operation::OP_noflags, 0, node->is_local (), node->is_abstract ()); get_op.set_defined_in (s); get_op.set_name (op_sn); UTL_ExceptList *get_exceptions = node->get_get_exceptions (); if (0 != get_exceptions) { get_op.be_add_exceptions (get_exceptions->copy ()); } be_visitor_context ctx (*this->ctx_); int status = 1; switch (this->ctx_->state ()) { // These two cases are the only ones that could involve a strategy. case TAO_CodeGen::TAO_ROOT_CH: case TAO_CodeGen::TAO_INTERFACE_CH: { ctx.state (TAO_CodeGen::TAO_OPERATION_CH); be_visitor_operation_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CS: { ctx.state (TAO_CodeGen::TAO_OPERATION_CS); be_visitor_operation_cs visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SH: { be_visitor_operation_sh visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IH: { be_visitor_operation_ih visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SS: { be_visitor_operation_ss visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IS: { be_visitor_operation_is visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: { be_visitor_operation_proxy_impl_xh visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: { be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: { be_visitor_operation_smart_proxy_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: { be_visitor_operation_smart_proxy_cs visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SH: { be_visitor_operation_tie_sh visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SS: { be_visitor_operation_tie_ss visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTH: case TAO_CodeGen::TAO_ROOT_SVH: { be_visitor_operation_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTS: case TAO_CodeGen::TAO_ROOT_SVS: { be_visitor_operation_svs visitor (&ctx); visitor.scope (this->op_scope_); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXH: { be_visitor_operation_ch visitor (&ctx); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXS: { be_visitor_operation_exs visitor (&ctx); visitor.scope (this->op_scope_); visitor.class_extension (this->exec_class_extension_.c_str ()); status = get_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CNH: case TAO_CodeGen::TAO_ROOT_CNS: break; default: get_op.destroy (); return 0; } if (status == -1) { get_op.destroy (); ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for get_attribute failed\n"), -1); } // Do nothing for readonly attributes. if (node->readonly ()) { get_op.destroy (); return 0; } status = 1; // Create the set method. Identifier id ("void"); UTL_ScopedName sn (&id, 0); // The return type is "void". be_predefined_type rt (AST_PredefinedType::PT_void, &sn); // Argument type is the same as the attribute type. AST_Argument *arg = idl_global->gen ()->create_argument (AST_Argument::dir_IN, node->field_type (), node->name ()); arg->set_name ((UTL_IdList *) node->name ()->copy ()); // Create the operation. be_operation set_op (&rt, AST_Operation::OP_noflags, 0, node->is_local (), node->is_abstract ()); set_op.set_defined_in (node->defined_in ()); set_op.set_name (static_cast<UTL_ScopedName *> (op_sn->copy ())); set_op.be_add_argument (arg); UTL_ExceptList *set_exceptions = node->get_set_exceptions (); if (0 != set_exceptions) { set_op.be_add_exceptions (set_exceptions->copy ()); } ctx = *this->ctx_; status = 1; switch (this->ctx_->state ()) { // These two cases are the only ones that could involved a strategy. case TAO_CodeGen::TAO_ROOT_CH: case TAO_CodeGen::TAO_INTERFACE_CH: { ctx.state (TAO_CodeGen::TAO_OPERATION_CH); be_visitor_operation_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CS: { ctx.state (TAO_CodeGen::TAO_OPERATION_CS); be_visitor_operation_cs visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SH: { be_visitor_operation_sh visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IH: { be_visitor_operation_ih visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SS: { be_visitor_operation_ss visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_IS: { be_visitor_operation_is visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: { be_visitor_operation_proxy_impl_xh visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: { be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: { be_visitor_operation_smart_proxy_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: { be_visitor_operation_smart_proxy_cs visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SH: { be_visitor_operation_tie_sh visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_TIE_SS: { be_visitor_operation_tie_ss visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTH: case TAO_CodeGen::TAO_ROOT_SVH: { be_visitor_operation_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_SVTS: case TAO_CodeGen::TAO_ROOT_SVS: { be_visitor_operation_svs visitor (&ctx); visitor.scope (this->op_scope_); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXH: { be_visitor_operation_ch visitor (&ctx); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_EXS: { be_visitor_operation_exs visitor (&ctx); visitor.scope (this->op_scope_); visitor.class_extension (this->exec_class_extension_.c_str ()); status = set_op.accept (&visitor); break; } case TAO_CodeGen::TAO_ROOT_CNH: case TAO_CodeGen::TAO_ROOT_CNS: break; default: // Error. set_op.destroy (); rt.destroy (); ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "bad codegen state\n"), -1); } if (status == 0) { get_op.destroy (); set_op.destroy (); rt.destroy (); return 0; } else if (status == -1) { get_op.destroy (); set_op.destroy (); rt.destroy (); ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for get_attribute failed\n"), -1); } get_op.destroy (); set_op.destroy (); rt.destroy (); return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_Auto_Ptr< sig_i > sig_impl; try { Consumer_Client client; int status = client.init (argc, argv); ACE_UNUSED_ARG(status); ACE_ASSERT(status == 0); CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 0); CORBA::ORB_ptr orb = client.orb (); sig_impl.reset( new sig_i( orb ) ); sig_var sig = sig_impl->_this (); CORBA::String_var ior = orb->object_to_string (sig.in ()); if (ior_output_file != 0) { FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file %s for " "writing IOR: %C", ior_output_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } CosNotifyChannelAdmin::SupplierAdmin_var admin = create_supplieradmin (ec.in ()); ACE_ASSERT(!CORBA::is_nil (admin.in ())); create_suppliers (admin.in (), &client); sig_impl->wait_for_startup(); ACE_DEBUG((LM_DEBUG, "%i supplier(s) sending %d events...\n", supplier_count, event_count)); for (int i = 0; i < event_count; ++i) { ACE_DEBUG((LM_DEBUG, "+")); SendEvent (i); } ACE_DEBUG((LM_DEBUG, "\nEach Supplier sent %d events.\n", event_count)); sig_impl->wait_for_completion(); ACE_OS::unlink (ior_output_file); disconnect_suppliers(); ec->destroy(); return 0; } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: "); } return 1; }
int PP_Test_Client::init (int argc, ACE_TCHAR **argv) { this->argc_ = argc; this->argv_ = argv; try { // Retrieve the ORB. this->orb_ = CORBA::ORB_init (this->argc_, this->argv_, "internet"); // Parse command line and verify parameters. if (this->parse_args () == -1) { return -1; } if (this->factory_key_ == 0) { ACE_ERROR_RETURN ((LM_ERROR, "%s: no factory key specified\n", this->argv_[0]), -1); } CORBA::Object_var factory_object = this->orb_->string_to_object (this->factory_key_); this->factory_ = Pluggable_Test_Factory::_narrow (factory_object.in()); if (CORBA::is_nil (this->factory_.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "invalid factory key <%s>\n", this->factory_key_), -1); } ACE_DEBUG ((LM_DEBUG, "Factory received OK\n")); // Now retrieve the Pluggable_Test obj ref corresponding to the key. ACE_FUNCTION_TIMEPROBE (PP_TEST_CLIENT_MAKE_PLUGGABLE_START); this->objref_ = this->factory_->make_pluggable_test (); if (CORBA::is_nil (this->objref_.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "null objref returned by factory\n"), -1); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Pluggable_Test::init"); return -1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { /// Move the test to the real-time class if it is possible. RT_Class rt_class; try { ORB_Holder orb (argc, argv, ""); if (parse_args (argc, argv) != 0) return 1; RTServer_Setup rtserver_setup (use_rt_corba, orb, rt_class, nthreads); PortableServer::POA_var root_poa = RIR_Narrow<PortableServer::POA>::resolve (orb, "RootPOA"); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); PortableServer::POA_var the_poa (rtserver_setup.poa ()); Servant_var<Roundtrip> roundtrip (new Roundtrip (orb)); PortableServer::ObjectId_var id = the_poa->activate_object (roundtrip.in ()); CORBA::Object_var object = the_poa->id_to_reference (id.in ()); CORBA::String_var ior = orb->object_to_string (object.in ()); // Output the ior to the <ior_output_file> FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
// This is the active reconnect implementation. The backoff algorithm is used as the // reconnect strategy. e.g. // With conn_retry_initial_interval = 500, conn_retry_backoff_multiplier = 2.0 and // conn_retry_attempts = 6 the reconnect attempts will be: // - first at 0 seconds(upon detection of the disconnect) // - second at 0.5 seconds // - third at 1.0 (2*0.5) seconds // - fourth at 2.0 (2*1.0) seconds // - fifth at 4.0 (2*2.0) seconds // - sixth at 8.0 (2*4.0) seconds int OpenDDS::DCPS::TcpConnection::active_reconnect_i() { DBG_ENTRY_LVL("TcpConnection","active_reconnect_i",6); GuardType guard(this->reconnect_lock_); VDBG((LM_DEBUG, "(%P|%t) DBG: " "active_reconnect_i(%C:%d->%C:%d) reconnect_state = %d\n", this->remote_address_.get_host_addr(), this->remote_address_.get_port_number(), this->local_address_.get_host_addr(), this->local_address_.get_port_number(), this->reconnect_state_)); if (DCPS_debug_level >= 1) { ACE_DEBUG((LM_DEBUG, "(%P|%t) DBG: TcpConnection::" "active_reconnect_i(%C:%d->%C:%d) reconnect_state = %d\n", this->remote_address_.get_host_addr(), this->remote_address_.get_port_number(), this->local_address_.get_host_addr(), this->local_address_.get_port_number(), this->reconnect_state_)); } // We need reset the state to INIT_STATE if we are previously reconnected. // This would allow re-establishing connection after the re-established // connection lost again. if (ACE_OS::gettimeofday() - this->last_reconnect_attempted_ > reconnect_delay && this->reconnect_state_ == RECONNECTED_STATE) { VDBG((LM_DEBUG, "(%P|%t) DBG: " "We are in RECONNECTED_STATE and now flip reconnect state to INIT_STATE.\n")); this->reconnect_state_ = INIT_STATE; } if (this->reconnect_state_ == INIT_STATE) { // Suspend send once. this->send_strategy_->suspend_send(); this->disconnect(); if (this->tcp_config_->conn_retry_attempts_ > 0) { this->link_->notify(DataLink::DISCONNECTED); } // else the conn_retry_attempts is 0 then we do not need this extra // notify_disconnected() since the user application should get the // notify_lost() without delay. double retry_delay_msec = this->tcp_config_->conn_retry_initial_delay_; int ret = -1; for (int i = 0; i < this->tcp_config_->conn_retry_attempts_; ++i) { ret = this->active_establishment(); if (this->shutdown_) break; if (ret == -1) { ACE_Time_Value delay_tv(((int)retry_delay_msec)/1000, ((int)retry_delay_msec)%1000*1000); ACE_OS::sleep(delay_tv); retry_delay_msec *= this->tcp_config_->conn_retry_backoff_multiplier_; } else { break; } } if (ret == -1) { if (this->tcp_config_->conn_retry_attempts_ > 0) { ACE_DEBUG((LM_DEBUG, "(%P|%t) we tried and failed to re-establish connection on transport: %C to %C:%d.\n", this->link_->get_transport_impl()->config()->name().c_str(), this->remote_address_.get_host_addr(), this->remote_address_.get_port_number())); } else { ACE_DEBUG((LM_DEBUG, "(%P|%t) we did not try to re-establish connection on transport: %C to %C:%d.\n", this->link_->get_transport_impl()->config()->name().c_str(), this->remote_address_.get_host_addr(), this->remote_address_.get_port_number())); } this->reconnect_state_ = LOST_STATE; this->link_->notify(DataLink::LOST); this->send_strategy_->terminate_send(); } else { ACE_DEBUG((LM_DEBUG, "(%P|%t) re-established connection on transport: %C to %C:%d.\n", this->link_->get_transport_impl()->config()->name().c_str(), this->remote_address_.get_host_addr(), this->remote_address_.get_port_number())); if (this->receive_strategy_->get_reactor()->register_handler(this, ACE_Event_Handler::READ_MASK) == -1) { ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) ERROR: OpenDDS::DCPS::TcpConnection::active_reconnect_i() can't register " "with reactor %X %p\n", this, ACE_TEXT("register_handler")), -1); } this->reconnect_state_ = RECONNECTED_STATE; this->link_->notify(DataLink::RECONNECTED); this->send_strategy_->resume_send(); } this->last_reconnect_attempted_ = ACE_OS::gettimeofday(); } return this->reconnect_state_ == LOST_STATE ? -1 : 0; }