int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; try { ACE_Argv_Type_Converter satc (argc, argv); CORBA::ORB_var sorb = CORBA::ORB_init (satc.get_argc (), satc.get_TCHAR_argv (), server_orb.c_str ()); ACE_Manual_Event me; Server_Task server_task (output, sorb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } // Wait for the server thread to do some processing me.wait (); ACE_Argv_Type_Converter catc (argc, argv); CORBA::ORB_var corb = CORBA::ORB_init (catc.get_argc (), catc.get_TCHAR_argv (), client_orb.c_str ()); Client_Task client_task (input, corb.in (), syncMode, ACE_Thread_Manager::instance ()); if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } ACE_Thread_Manager::instance ()->wait (); } catch (const CORBA::Exception&) { // Ignore exceptions.. } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { //Use Real-time Scheduling class if possible set_priority(); try { CORBA::ORB_var sorb = CORBA::ORB_init (argc, argv); if (parse_args (argc,argv) == -1) return -1; ACE_Manual_Event wait_for_event; Server_Task server_task (sorb.in (), wait_for_event, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } // Wait for the server thread to do some processing wait_for_event.wait (); // Obtain the object reference Test::Roundtrip_var reference = server_task.get_reference (); Client_Task client_task (reference.in (), niterations, ACE_Thread_Manager::instance ()); if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } ACE_Thread_Manager::instance ()->wait (); } catch (const CORBA::Exception&) { // Ignore exceptions.. } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { 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 (); if (parse_args (argc, argv) != 0) return 1; Process_Factory *process_factory_impl = 0; ACE_NEW_RETURN (process_factory_impl, Process_Factory (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(process_factory_impl); PortableServer::ObjectId_var id = root_poa->activate_object (process_factory_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Process_Factory_var process = Test::Process_Factory::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (process.in ()); // If the ior_output_file exists, output the ior to it 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); poa_manager->activate (); Server_Task server_task (orb.in (), ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 8, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } ACE_Thread_Manager::instance ()->wait (); 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[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); CORBA::Object_var object = orb->resolve_initial_references ("PolicyCurrent"); CORBA::PolicyCurrent_var policy_current = CORBA::PolicyCurrent::_narrow (object.in ()); if (CORBA::is_nil (policy_current.in ())) { ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n")); return 1; } CORBA::Any scope_as_any; scope_as_any <<= Messaging::SYNC_NONE; CORBA::PolicyList policies (1); policies.length (1); policies[0] = orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, scope_as_any); policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); policies[0]->destroy (); if (parse_args (argc, argv) != 0) return 1; // Get the sender reference.. CORBA::Object_var tmp = orb->string_to_object(ior); Test::Sender_var sender = Test::Sender::_narrow(tmp.in ()); if (CORBA::is_nil (sender.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil coordinator reference <%s>\n", ior), 1); } Client_Task client_task (orb.in(), sender.in (), ACE_Thread_Manager::instance (), number_of_oneways); Server_Task server_task (orb.in (), ACE_Thread_Manager::instance ()); // Before creating threads we will let the sender know that we // will have two threads that would make invocations.. // this is the first oneway we do, so after this we would have a queue // on one of the transports sender->active_objects ((CORBA::Short) number_of_client_tasks); TAO::Transport_Cache_Manager& manager = orb->orb_core()->lane_resources ().transport_cache (); TAO::Transport_Cache_Manager::HASH_MAP& cachemap = manager.map(); TAO::Transport_Cache_Manager::HASH_MAP_ITER end_iter = cachemap.end (); bool tranportwithqueue = false; for (TAO::Transport_Cache_Manager::HASH_MAP_ITER iter = cachemap.begin (); iter != end_iter; ++iter) { TAO_Transport* transport = (*iter).int_id_.transport (); if (transport->queue_is_empty() == 0 && transport->is_connected() == false) { tranportwithqueue = true; break; } } if (!tranportwithqueue) { ACE_ERROR ((LM_ERROR, "(%P|%t) Error: expect a not connected transport with a queue\n")); } else { ACE_DEBUG((LM_DEBUG, "(%P|%t) Found not connected transport with a queue\n")); } if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 2,1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, number_of_client_tasks, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, "Event Loop finished\n")); orb->destroy (); if (tranportwithqueue == false) { return 1; } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; try { PortableInterceptor::ORBInitializer_ptr temp_initializer = PortableInterceptor::ORBInitializer::_nil (); // Set up our default expectations. CORBA::ULong expected_interceptor_check = 12; PortableInterceptor::ProcessingMode proc_mode = PortableInterceptor::LOCAL_AND_REMOTE; if (proc_mode_str == ACE_TEXT ("LOCAL_ONLY")) { proc_mode = PortableInterceptor::LOCAL_ONLY; ACE_DEBUG((LM_DEBUG, "Using LOCAL_ONLY for server-side ProcessingMode.\n")); // Since all of the calls are remote, setting the server-side // ProcessingMode to LOCAL_ONLY will cause the server request // interceptor to not fire. Thus, we expect 0 calls on the // server interceptor. expected_interceptor_check = 0; } else if (proc_mode_str == ACE_TEXT ("REMOTE_ONLY")) { proc_mode = PortableInterceptor::REMOTE_ONLY; ACE_DEBUG((LM_DEBUG, "Using REMOTE_ONLY for server-side ProcessingMode.\n")); } else { ACE_DEBUG((LM_DEBUG, "Using LOCAL_AND_REMOTE for server-side ProcessingMode.\n")); } ACE_NEW_RETURN (temp_initializer, Echo_Server_ORBInitializer (proc_mode), -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); ACE_Manual_Event me; Server_Task server_task (output, orb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } ACE_Thread_Manager::instance ()->wait (); CORBA::ULong number_called = Echo_Server_Request_Interceptor::server_interceptor_check_; if (number_called != expected_interceptor_check) { ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Server-Side Interceptors not " "called properly, called %d times, expected %d.\n", number_called, expected_interceptor_check)); return 1; } } catch (const CORBA::Exception&) { ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Some exception was caught in main().\n")); return 1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; try { // Start the Naming Service tasks NamingTask name_service ("NamingORBA", argc, argv); name_service.activate(); // Wait for the Naming Service initialized. name_service.waitInit(); ACE_Argv_Type_Converter satc (argc, argv); CORBA::ORB_var sorb = CORBA::ORB_init (satc.get_argc (), satc.get_TCHAR_argv (), server_orb.c_str ()); ACE_Manual_Event me; Server_Task server_task (name_service.root (), sorb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } // Wait for the server thread to do some processing me.wait (); ACE_Argv_Type_Converter catc (argc, argv); CORBA::ORB_var corb = CORBA::ORB_init (catc.get_argc (), catc.get_TCHAR_argv (), client_orb.c_str ()); Client_Task client_task (name_service.root (), corb.in (), ACE_Thread_Manager::instance (), result); if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } // Wait for the client and server to finish ACE_Thread_Manager::instance ()->wait (); // Now that all threads have completed we can destroy the ORB sorb->destroy (); if (server_orb != client_orb) { corb->destroy (); } } catch (const CORBA::Exception&) { // Ignore exceptions.. } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { ACE_Argv_Type_Converter main_args_s (argc, argv); CORBA::ORB_var sorb = CORBA::ORB_init (main_args_s.get_argc (), main_args_s.get_TCHAR_argv (), "Server_ORB"); // Parse command line if (parse_args (argc, argv) == -1) { return -1; } ACE_Manual_Event me; Server_Task server_task (ior_output_file, sorb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating the server task.")); return -1; } // Wait for the server task to activate. me.wait (); ACE_Argv_Type_Converter main_args_c (argc, argv); CORBA::ORB_var corb = CORBA::ORB_init (main_args_c.get_argc (), main_args_c.get_TCHAR_argv (), "Client_ORB"); { Client_Task client_task (ior_input_file, corb.in (), ACE_Thread_Manager::instance ()); if (client_task.activate (THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client thread.\n")); return -1; } ACE_Thread_Manager::instance ()->wait (); } corb->destroy (); } catch (const CORBA::Exception&) { // ignore exceptions } ACE_DEBUG ((LM_DEBUG, "Threaded client ready.\n")); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; try { ACE_Argv_Type_Converter satc (argc, argv); CORBA::ORB_var sorb = CORBA::ORB_init (satc.get_argc (), satc.get_TCHAR_argv (), server_orb.c_str ()); ACE_Manual_Event me; Server_Task server_task (output, simple_test_output, sorb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } // Wait for the server thread to do some processing me.wait (); ACE_Argv_Type_Converter catc (argc, argv); CORBA::ORB_var corb = CORBA::ORB_init (catc.get_argc (), catc.get_TCHAR_argv (), client_orb.c_str ()); Client_Task client_task (input, simple_test_input, corb.in (), ACE_Thread_Manager::instance ()); if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } // Wait for the client and server to finish ACE_Thread_Manager::instance ()->wait (); // Now that all threads have completed we can destroy the ORB sorb->destroy (); if (server_orb != client_orb) { corb->destroy (); } CORBA::ULong errors = client_task.error_count () + server_task.error_count (); if (errors == 0) { ACE_DEBUG((LM_DEBUG, "(%P|%t) test passed\n")); } else { ACE_DEBUG((LM_DEBUG, "(%P|%t) test failed - error_count=%u\n", errors)); return 1; } } catch (const CORBA::Exception&) { // Ignore exceptions.. } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, priority); priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, priority); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) { ACE_DEBUG ((LM_DEBUG, "server (%P|%t): user is not superuser, " "test runs in time-shared class\n")); } else ACE_ERROR ((LM_ERROR, "server (%P|%t): sched_params failed\n")); } try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; Roundtrip *roundtrip_impl; ACE_NEW_RETURN (roundtrip_impl, Roundtrip (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(roundtrip_impl); Test::Roundtrip_var roundtrip = roundtrip_impl->_this (); CORBA::String_var ior = orb->object_to_string (roundtrip.in ()); // If the ior_output_file exists, output the ior to it 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); poa_manager->activate (); Server_Task server_task (orb.in ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot activate server threads\n"), 1); server_task.thr_mgr ()->wait (); ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); 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[]) { if (parse_args (argc, argv) == -1) return -1; try { // Keep a copy of the ORB options args ACE_ARGV orb_args; for (int i = 1; i < argc; ++i) { if (orb_args.add (argv[i]) == -1) return -1; } ACE_Argv_Type_Converter satc (argc, argv); // This eats all orb-specific options! CORBA::ORB_var sorb = CORBA::ORB_init (satc.get_argc (), satc.get_TCHAR_argv (), server_orb.c_str ()); ACE_Manual_Event me; Server_Task server_task (output, sorb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } // Wait for the server thread to do some processing me.wait (); // Restore the orb-specific options. argc = orb_args.argc (); for (int i = 1; i < argc; ++i) { argv[i] = const_cast<ACE_TCHAR*> (orb_args[i]); } ACE_Argv_Type_Converter catc (argc, argv); CORBA::ORB_var corb = CORBA::ORB_init (catc.get_argc(), catc.get_TCHAR_argv(), client_orb.c_str ()); Client_Task client_task (input, corb.in (), ACE_Thread_Manager::instance ()); if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } // Wait for the client and server to finish ACE_Thread_Manager::instance ()->wait (); // Now that all threads have completed we can destroy the ORB sorb->destroy (); if (server_orb != client_orb) { corb->destroy (); } } catch (const CORBA::Exception&) { // Ignore exceptions.. } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; server_orb.set ("server_orb"); client_orb.set ("client_orb"); try { PortableInterceptor::ORBInitializer_ptr temp_initializer; ACE_NEW_RETURN (temp_initializer, Collocated_ORBInitializer, -1); // No exceptions yet! PortableInterceptor::ORBInitializer_var initializer = temp_initializer; PortableInterceptor::register_orb_initializer (initializer.in ()); CORBA::ORB_var sorb = CORBA::ORB_init (argc, argv, server_orb.c_str ()); ACE_Manual_Event me; Server_Task server_task (output, sorb.in (), me, ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } // Wait for the server thread to do some processing me.wait (); CORBA::ORB_var corb = CORBA::ORB_init (argc, argv, client_orb.c_str ()); Client_Task client_task (input, corb.in (), ACE_Thread_Manager::instance ()); if (client_task.activate (THR_NEW_LWP | THR_JOINABLE, 1, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating client task\n")); } ACE_Thread_Manager::instance ()->wait (); } catch (const CORBA::Exception&) { // Ignore exceptions.. } return 0; }
int main(int argc, const char *argv[]) { try { LogPolicy::GetInstance().Unmute(); bool trial_run = false; std::string ip_address; int ip_port, requested_thread_num; libosrm_config lib_config; const unsigned init_result = GenerateServerProgramOptions( argc, argv, lib_config.server_paths, ip_address, ip_port, requested_thread_num, lib_config.use_shared_memory, trial_run, lib_config.max_locations_distance_table, lib_config.max_locations_map_matching); if (init_result == INIT_OK_DO_NOT_START_ENGINE) { return 0; } if (init_result == INIT_FAILED) { return 1; } #ifdef __linux__ const int lock_flags = MCL_CURRENT | MCL_FUTURE; if (-1 == mlockall(lock_flags)) { SimpleLogger().Write(logWARNING) << argv[0] << " could not be locked to RAM"; } #endif SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION; if (lib_config.use_shared_memory) { SimpleLogger().Write(logDEBUG) << "Loading from shared memory"; } SimpleLogger().Write(logDEBUG) << "Threads:\t" << requested_thread_num; SimpleLogger().Write(logDEBUG) << "IP address:\t" << ip_address; SimpleLogger().Write(logDEBUG) << "IP port:\t" << ip_port; #ifndef _WIN32 int sig = 0; sigset_t new_mask; sigset_t old_mask; sigfillset(&new_mask); pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); #endif OSRM osrm_lib(lib_config); auto routing_server = Server::CreateServer(ip_address, ip_port, requested_thread_num); routing_server->GetRequestHandlerPtr().RegisterRoutingMachine(&osrm_lib); if (trial_run) { SimpleLogger().Write() << "trial run, quitting after successful initialization"; } else { std::packaged_task<int()> server_task([&]() -> int { routing_server->Run(); return 0; }); auto future = server_task.get_future(); std::thread server_thread(std::move(server_task)); #ifndef _WIN32 sigset_t wait_mask; pthread_sigmask(SIG_SETMASK, &old_mask, 0); sigemptyset(&wait_mask); sigaddset(&wait_mask, SIGINT); sigaddset(&wait_mask, SIGQUIT); sigaddset(&wait_mask, SIGTERM); pthread_sigmask(SIG_BLOCK, &wait_mask, 0); SimpleLogger().Write() << "running and waiting for requests"; sigwait(&wait_mask, &sig); #else // Set console control handler to allow server to be stopped. console_ctrl_function = std::bind(&Server::Stop, routing_server); SetConsoleCtrlHandler(console_ctrl_handler, TRUE); SimpleLogger().Write() << "running and waiting for requests"; routing_server->Run(); #endif SimpleLogger().Write() << "initiating shutdown"; routing_server->Stop(); SimpleLogger().Write() << "stopping threads"; auto status = future.wait_for(std::chrono::seconds(2)); if (status == std::future_status::ready) { server_thread.join(); } else { SimpleLogger().Write(logWARNING) << "Didn't exit within 2 seconds. Hard abort!"; server_task.reset(); // just kill it } } SimpleLogger().Write() << "freeing objects"; routing_server.reset(); SimpleLogger().Write() << "shutdown completed"; } catch (const std::exception &e) { SimpleLogger().Write(logWARNING) << "exception: " << e.what(); return 1; } #ifdef __linux__ munlockall(); #endif return 0; }
int main() { server_task(); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; Sender_i *sender_impl; ACE_NEW_RETURN (sender_impl, Sender_i (orb.in ()), 1); PortableServer::ServantBase_var receiver_owner_transfer(sender_impl); PortableServer::ObjectId_var id = root_poa->activate_object (sender_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Sender_var sender = Test::Sender::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (sender.in ()); // If the ior_output_file exists, output the ior to it 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); poa_manager->activate (); Server_Task server_task (orb.in (), ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, "Now terminating test\n")); CORBA::ULong activeobjects = sender_impl->get_active_objects (); if (((number_of_oneways * activeobjects) != sender_impl->get_number_received ()) && activeobjects != 0) { ACE_ERROR ((LM_ERROR, "Error, expected %d oneways, received %d\n", number_of_oneways, sender_impl->get_number_received())); } else { if (sender_impl->get_number_received () == 0) { ACE_ERROR ((LM_ERROR, "Error: Received no calls\n")); } else { ACE_DEBUG ((LM_DEBUG, "Corrected amount received\n")); } } root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }