diff options
Diffstat (limited to 'tests/MT_NoUpcall_Client_Leader')
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/MT_NoUpcall.mpc | 48 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/README | 29 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/SharedIntf.idl | 8 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/SharedIntf_i.cpp | 27 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/SharedIntf_i.h | 25 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/chatter.cpp | 93 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/chatter.h | 26 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/client.cpp | 167 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/mt_noupcall.conf | 3 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/police.cpp | 13 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/police.h | 3 | ||||
-rwxr-xr-x | tests/MT_NoUpcall_Client_Leader/run_test.pl | 91 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/server.cpp | 144 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/worker.cpp | 23 | ||||
-rw-r--r-- | tests/MT_NoUpcall_Client_Leader/worker.h | 32 |
15 files changed, 732 insertions, 0 deletions
diff --git a/tests/MT_NoUpcall_Client_Leader/MT_NoUpcall.mpc b/tests/MT_NoUpcall_Client_Leader/MT_NoUpcall.mpc new file mode 100644 index 00000000000..a11e11f20a6 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/MT_NoUpcall.mpc @@ -0,0 +1,48 @@ +// -*- MPC -*- +// $Id$ + + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + SharedIntf.idl + } + custom_only = 1 +} + +project(*Server): messaging, taoserver, threads { + exename = server + after += *idl + Source_Files { + SharedIntf_i.cpp + server.cpp + worker.cpp + chatter.cpp + police.cpp + } + Source_Files { + SharedIntfC.cpp + SharedIntfS.cpp + } + IDL_Files { + } +} + +project(*Client): messaging, taoserver, threads { + exename = client + after += *idl + Source_Files { + SharedIntf_i.cpp + client.cpp + worker.cpp + chatter.cpp + police.cpp + } + Source_Files { + SharedIntfC.cpp + SharedIntfS.cpp + } + IDL_Files { + } +} + diff --git a/tests/MT_NoUpcall_Client_Leader/README b/tests/MT_NoUpcall_Client_Leader/README new file mode 100644 index 00000000000..f8174c18bc2 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/README @@ -0,0 +1,29 @@ +// $Id$ + +The test simulates a case when an incomming requests is being detected while a +client-leader thread is waiting in the reactor event loop for its own reply. + +The server uses MT_NOUPCALL client connection handling strategy. The defect was +in the fact that while the above described incomming request was correctly not +being handled, the corresponding transport handle remained suspended. This +caused the reactor to exclude that handle from the read mask and it never gave +other followers a chance to read from that handle. Eventually, these requests +remained "ignored" + +The resolution is to resume the handle *and* notify the reactor when an +incomming requests is being detected, while a client-leader thread is waiting +in the reactor event loop for its own reply. Thus, if any follower threads are +available, they can pick it up and process it eventually. + +A rapidly increasing spin prevention back-off delay helps to mitigate the +negative influence of this solution over the processor utilization. + +Run the test by starting the server: + + ./server -ORBSvcConf mt_noupcall.conf + +And the client: + + ./client + +If any requests get "ignored" the server process will hang indefinitely. diff --git a/tests/MT_NoUpcall_Client_Leader/SharedIntf.idl b/tests/MT_NoUpcall_Client_Leader/SharedIntf.idl new file mode 100644 index 00000000000..0081a42b4d0 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/SharedIntf.idl @@ -0,0 +1,8 @@ +// $Id$ + +module Test_Idl { + interface SharedIntf { + void ping(); + oneway void farewell(); + }; +}; diff --git a/tests/MT_NoUpcall_Client_Leader/SharedIntf_i.cpp b/tests/MT_NoUpcall_Client_Leader/SharedIntf_i.cpp new file mode 100644 index 00000000000..4fcaa2aae6c --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/SharedIntf_i.cpp @@ -0,0 +1,27 @@ +// $Id$ + +#include "SharedIntf_i.h" +#include "ace/Log_Priority.h" +#include "ace/OS_NS_unistd.h" + +Test_Idl_SharedIntf_i::Test_Idl_SharedIntf_i(CORBA::ORB_ptr orb) + : orb_ (orb) +{ +} + +Test_Idl_SharedIntf_i::~Test_Idl_SharedIntf_i(void) {} + +void Test_Idl_SharedIntf_i::ping () +{ + ACE_DEBUG((LM_DEBUG,"(%P|%t) Test_Idl_SharedIntf::ping - sleeping for 5 seconds\n")); + ACE_OS::sleep(5); + ACE_DEBUG((LM_DEBUG,"(%P|%t) Test_Idl_SharedIntf::ping - waking up\n")); +} + +void Test_Idl_SharedIntf_i::farewell () +{ + ACE_DEBUG((LM_INFO,"(%P|%t) farewell begins\n")); + this->orb_->shutdown (); + ACE_DEBUG((LM_INFO,"(%P|%t) farewell completes\n")); +} + diff --git a/tests/MT_NoUpcall_Client_Leader/SharedIntf_i.h b/tests/MT_NoUpcall_Client_Leader/SharedIntf_i.h new file mode 100644 index 00000000000..3926689bcd1 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/SharedIntf_i.h @@ -0,0 +1,25 @@ +// $Id$ + +#ifndef SHAREDINTF_I_H_ +#define SHAREDINTF_I_H_ + +#include "SharedIntfS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class Test_Idl_SharedIntf_i : public virtual POA_Test_Idl::SharedIntf +{ + public: + + Test_Idl_SharedIntf_i (CORBA::ORB_ptr orb); + virtual ~Test_Idl_SharedIntf_i (void); + + virtual void ping (); + virtual void farewell (); + private: + CORBA::ORB_ptr orb_; +}; + +#endif /* SHAREDINTF_I_H_ */ diff --git a/tests/MT_NoUpcall_Client_Leader/chatter.cpp b/tests/MT_NoUpcall_Client_Leader/chatter.cpp new file mode 100644 index 00000000000..6a9248bda6f --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/chatter.cpp @@ -0,0 +1,93 @@ +// $Id$ + +#include "SharedIntf_i.h" +#include "worker.h" +#include "chatter.h" + +Chatter::Chatter (CORBA::ORB_ptr orb, const ACE_TCHAR *ior, ACE_Condition<ACE_Mutex>& cond) + : Worker (orb), + nrequests_ (0), + nreplies_ (0), + ior_ (ior), + cond_ (cond) +{ +} + +long +Chatter::nreplies (void) +{ + return this->nreplies_; +} + +long +Chatter::nrequests (void) +{ + return this->nrequests_; +} + +int +Chatter::svc (void) +{ + long nrq = nrequests (); + try + { + //sleep(1); + + // get server ior from file + CORBA::Object_var rawObject = orb_->string_to_object(ior_); + + Test_Idl::SharedIntf_var intf_var = + Test_Idl::SharedIntf::_narrow(rawObject.in()); + + if (CORBA::is_nil (intf_var.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", ior_), -1); + + // make call on server + ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] started for %s\n", nrq, ior_)); + nrequests_++; + intf_var->ping(); + nreplies_++; + + ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] completed for %s\n", nrq, ior_)); + cond_.signal(); + return 0; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] %p for %s\n", nrq, "failed", ior_)); + } + return -1; +} + +int +Chatter::farewell () +{ + try + { + ACE_DEBUG((LM_INFO,"(%P|%t) Farewell requested for %s\n", ior_)); + + // get server ior from file + CORBA::Object_var rawObject = orb_->string_to_object( ior_); + + Test_Idl::SharedIntf_var intf_var = + Test_Idl::SharedIntf::_narrow(rawObject.in()); + + if (CORBA::is_nil (intf_var.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", ior_), -1); + + // make call on server + ACE_DEBUG((LM_INFO,"(%P|%t) farewell START for %s\n", ior_)); + intf_var->farewell(); + + ACE_DEBUG((LM_INFO,"(%P|%t) farewell COMPLETE for %s\n", ior_)); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + ACE_DEBUG((LM_INFO,"(%P|%t) %p for %s\n", "farewell FAILED", ior_)); + } + return 0; +} + + diff --git a/tests/MT_NoUpcall_Client_Leader/chatter.h b/tests/MT_NoUpcall_Client_Leader/chatter.h new file mode 100644 index 00000000000..8e5a313a0fa --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/chatter.h @@ -0,0 +1,26 @@ +// $Id$ + +#if !defined( CHATTER_H) +#define CHATTER_H + +#include "worker.h" + +#include "ace/Condition_T.h" +#include "ace/Mutex.h" + +class Chatter : public Worker +{ +public: + Chatter (CORBA::ORB_ptr orb, const ACE_TCHAR *ior, ACE_Condition<ACE_Mutex>& cond); + virtual int svc (void); + int farewell (); + long nrequests (void); + long nreplies (void); +public: + long nrequests_; + long nreplies_; +private: + const ACE_TCHAR* ior_; + ACE_Condition<ACE_Mutex>& cond_; +}; +#endif /* CHATTER_H */ diff --git a/tests/MT_NoUpcall_Client_Leader/client.cpp b/tests/MT_NoUpcall_Client_Leader/client.cpp new file mode 100644 index 00000000000..fafa60c74d1 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/client.cpp @@ -0,0 +1,167 @@ +// $Id$ + +#include "SharedIntf_i.h" +#include "worker.h" +#include "chatter.h" +#include "police.h" + +#include "ace/SString.h" +#include "ace/Get_Opt.h" + +const ACE_TCHAR *ior_output_file = ACE_TEXT ("client.ior"); +int nr_threads = 1; + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("t:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 't': + nr_threads = ACE_OS::atoi(get_opts.opt_arg ()); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-t threads " + "\n", + argv [0]), + -1); + } + // Indicates successful parsing of the command line + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + CORBA::ORB_var orb_; + int result = 0; + + try + { + ACE_DEBUG((LM_INFO,"(%P|%t) START OF CLIENT TEST\n")); + + orb_ = CORBA::ORB_init (argc, argv, "myorb-client"); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var poa_object = + orb_->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + PortableServer::POA_var poa = root_poa; + + poa_manager->activate (); + + // Creating the monitorable servant and activating it + // + Test_Idl_SharedIntf_i* intf_i = new Test_Idl_SharedIntf_i (orb_.in()); + + PortableServer::ServantBase_var base_var = intf_i; + PortableServer::ObjectId_var intfId_var = + poa->activate_object (base_var.in()); + + CORBA::Object_var obj_var = + poa->id_to_reference (intfId_var.in()); + + Test_Idl::SharedIntf_var intf_var = + Test_Idl::SharedIntf::_narrow (obj_var.in()); + + // Creating stringified IOR of the servant and writing it to a file. + // + CORBA::String_var intfString_var = + orb_->object_to_string (intf_var.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\n", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", intfString_var.in ()); + ACE_OS::fclose (output_file); + + ACE_DEBUG ((LM_INFO,"(%P|%t) client IOR to %s\n", ior_output_file)); + + // Running ORB in separate thread + Worker worker (orb_.in ()); + if (worker.activate (THR_NEW_LWP | THR_JOINABLE, nr_threads) != 0) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", + "Cannot activate client threads"), -1); + + ACE_DEBUG((LM_INFO,"(%P|%t) Await server initialization\n")); + poll ("./server.ior"); + ACE_DEBUG((LM_INFO,"(%P|%t) Server IOR file was detected\n")); + + ACE_Mutex mutex; + ACE_Condition<ACE_Mutex> stop_condition (mutex); + + const ACE_TCHAR* serverior = ACE_TEXT("file://server.ior"); + Chatter worker2 (orb_.in (), serverior, stop_condition); + + if (worker2.activate (THR_NEW_LWP | THR_JOINABLE, 2) != 0) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", + "Cannot activate chatty client threads"), -1); + + + do { + stop_condition.wait (); + ACE_DEBUG((LM_INFO,"(%P|%t) So far, %d/%d requests/replies have been processed\n", + worker2.nrequests (), worker2.nreplies ())); + } + while (worker2.nreplies () < 2); + + // Kill the peer + { + CORBA::Object_var rawObject = orb_->string_to_object( serverior); + + Test_Idl::SharedIntf_var intf_var = + Test_Idl::SharedIntf::_narrow(rawObject.in()); + + if (CORBA::is_nil (intf_var.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", serverior), -1); + + // make call on server + ACE_DEBUG((LM_INFO,"(%P|%t) farewell START for %s\n", serverior)); + + intf_var->farewell(); + + ACE_DEBUG((LM_INFO,"(%P|%t) farewell COMPLETE for %s\n", serverior)); + } + + ACE_DEBUG((LM_INFO,"(%P|%t) END OF CLIENT TEST\n")); + + orb_.in()->shutdown (); + + worker.thr_mgr()->wait (); + + root_poa->destroy(1,1); + + orb_->destroy(); + + ACE_DEBUG((LM_INFO,"(%P|%t) Client Test %C\n", + (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed")); + + result = (worker2.nrequests_ == worker2.nreplies_)? 0 : -1; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Error: Exception caught:"); + } + + ACE_OS::unlink ("client.ior"); + return result; +} + diff --git a/tests/MT_NoUpcall_Client_Leader/mt_noupcall.conf b/tests/MT_NoUpcall_Client_Leader/mt_noupcall.conf new file mode 100644 index 00000000000..f503eb428e8 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/mt_noupcall.conf @@ -0,0 +1,3 @@ +# $Id$ + +static Client_Strategy_Factory "-ORBClientconnectionHandler mt_noupcall" diff --git a/tests/MT_NoUpcall_Client_Leader/police.cpp b/tests/MT_NoUpcall_Client_Leader/police.cpp new file mode 100644 index 00000000000..17eb4ea649e --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/police.cpp @@ -0,0 +1,13 @@ +// $Id$ + +#include "ace/OS_NS_sys_stat.h" +#include "ace/OS_NS_unistd.h" + +void poll (const char* filename) +{ + ACE_stat st; + for (int r=1; r != 0; r = ACE_OS::stat (filename, &st)) + { + ACE_OS::sleep (1); + } +} diff --git a/tests/MT_NoUpcall_Client_Leader/police.h b/tests/MT_NoUpcall_Client_Leader/police.h new file mode 100644 index 00000000000..af3144b1292 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/police.h @@ -0,0 +1,3 @@ +// $Id$ + +void poll (const char* filename); diff --git a/tests/MT_NoUpcall_Client_Leader/run_test.pl b/tests/MT_NoUpcall_Client_Leader/run_test.pl new file mode 100755 index 00000000000..d64c2393165 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/run_test.pl @@ -0,0 +1,91 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; +my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n"; + +my $client_conf = $server->LocalFile ("mt_noupcall$PerlACE::svcconf_ext"); +my $server_conf = $server->LocalFile ("mt_noupcall$PerlACE::svcconf_ext"); + +$debug_level = '0'; + +foreach $i (@ARGV) { + if ($i eq '-d') { + $debug_level = '10'; + } +} + +my $server_iorbase = "server.ior"; +my $client_iorbase = "client.ior"; +my $server_iorfile = $server->LocalFile ($server_iorbase); +my $client_iorfile = $client->LocalFile ($client_iorbase); + +$server->DeleteFile($server_iorbase); +$client->DeleteFile($client_iorbase); + +$SV = $server->CreateProcess ("server", + "-ORBDebugLevel $debug_level -ORBSvcConf $server_conf " . + "-t 1"); + +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +if ($server->WaitForFileTimed ($server_iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$CL = $client->CreateProcess ("client", "-t 1"); + +$client_status = $CL->Spawn (); + +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +if ($client->WaitForFileTimed ($client_iorbase, + $client->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$client_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +print "INFO: Awaiting server ...\n"; + +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 30); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; +} + +print "INFO: Awaiting client ...\n"; + +$client_status = $CL->WaitKill ($client->ProcessStartWaitInterval()); + +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $status = 1; +} + +$server->DeleteFile($server_iorfile); +$client->DeleteFile($client_iorfile); + +print "INFO: Test succeeded\n"; +exit 0; + diff --git a/tests/MT_NoUpcall_Client_Leader/server.cpp b/tests/MT_NoUpcall_Client_Leader/server.cpp new file mode 100644 index 00000000000..b8e2e942dbc --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/server.cpp @@ -0,0 +1,144 @@ +// $Id$ + +#include "SharedIntf_i.h" +#include "worker.h" +#include "chatter.h" +#include "police.h" + +#include "ace/SString.h" +#include "ace/Get_Opt.h" + +const ACE_TCHAR *ior_output_file = ACE_TEXT ("server.ior"); +int nr_threads = 1; + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("t:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 't': + nr_threads = ACE_OS::atoi(get_opts.opt_arg ()); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-t threads " + "\n", + argv [0]), + -1); + } + // Indicates successful parsing of the command line + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + CORBA::ORB_var orb_; + int result = 0; + + try + { + ACE_DEBUG((LM_INFO,"(%P|%t) START OF SERVER TEST\n")); + + orb_ = CORBA::ORB_init (argc, argv, "myorb-server"); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var poa_object = + orb_->resolve_initial_references("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + PortableServer::POA_var poa = root_poa; + + poa_manager->activate (); + + ACE_DEBUG((LM_INFO,"(%P|%t) ORB initialized\n")); + + // Creating the servant and activating it + // + Test_Idl_SharedIntf_i* intf_i = new Test_Idl_SharedIntf_i(orb_.in()); + + PortableServer::ServantBase_var base_var = intf_i; + PortableServer::ObjectId_var intfId_var = + poa->activate_object(base_var.in()); + + CORBA::Object_var obj_var = + poa->id_to_reference(intfId_var.in()); + + Test_Idl::SharedIntf_var intf_var = + Test_Idl::SharedIntf::_narrow(obj_var.in()); + + // Creating stringified IOR of the servant and writing it to a file. + // + CORBA::String_var intfString_var = + orb_->object_to_string(intf_var.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\n", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", intfString_var.in ()); + ACE_OS::fclose (output_file); + + ACE_DEBUG((LM_INFO,"(%P|%t) server IOR to %s\n", + ior_output_file)); + + // Running ORB in separate thread + Worker worker (orb_.in ()); + if (worker.activate (THR_NEW_LWP | THR_JOINABLE, nr_threads) != 0) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "Cannot activate server thread(s)"), -1); + + ACE_DEBUG((LM_INFO,"(%P|%t) Await client initialization\n")); + poll ("./client.ior"); + ACE_DEBUG((LM_INFO,"(%P|%t) Client IOR file was detected\n")); + + ACE_Mutex mutex; + ACE_Condition<ACE_Mutex> stop_condition (mutex); + + Chatter worker2 (orb_.in (), ACE_TEXT("file://client.ior"), stop_condition); + if (worker2.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "Cannot activate chatty client threads"), -1); + } + + do { + stop_condition.wait (); + ACE_DEBUG((LM_INFO,"(%P|%t) So far, %d/%d requests/replies have been processed\n", + worker2.nrequests (), worker2.nreplies ())); + } + while (worker2.nrequests () < 1); + + worker.thr_mgr()->wait (); + + root_poa->destroy(1, 1); + + orb_->destroy(); + + ACE_DEBUG((LM_INFO,"(%P|%t) Server Test %C\n", + (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed")); + result = (worker2.nrequests() == worker2.nreplies())? 0 : -1; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Error: Exception caught:"); + } + + ACE_OS::unlink ("server.ior"); + return result; +} + diff --git a/tests/MT_NoUpcall_Client_Leader/worker.cpp b/tests/MT_NoUpcall_Client_Leader/worker.cpp new file mode 100644 index 00000000000..5c5041b6418 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/worker.cpp @@ -0,0 +1,23 @@ +// $Id$ + +#include "worker.h" + +Worker::Worker (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +int +Worker::svc (void) +{ + ACE_DEBUG((LM_INFO,"(%P|%t) Running ORB in a separate thread\n")); + try + { + this->orb_->run (); + } + catch (const CORBA::Exception&) + { + } + return 0; +} + diff --git a/tests/MT_NoUpcall_Client_Leader/worker.h b/tests/MT_NoUpcall_Client_Leader/worker.h new file mode 100644 index 00000000000..55146024151 --- /dev/null +++ b/tests/MT_NoUpcall_Client_Leader/worker.h @@ -0,0 +1,32 @@ +// $Id$ + +#if !defined( WORKER_H) +#define WORKER_H + +#include /**/ "ace/pre.h" +#include "tao/corba.h" +#include "ace/Task.h" + +class Worker : public ACE_Task_Base +{ + // = TITLE + // Run a server thread + // + // = DESCRIPTION + // Use the ACE_Task_Base class to run server threads + // +public: + Worker (CORBA::ORB_ptr orb); + // ctor + + virtual int svc (void); + // The thread entry point. + +public: + // The orb + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" + +#endif /* WORKER_H */ |