summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2011-06-10 12:44:51 +0000
committersma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2011-06-10 12:44:51 +0000
commit8fb76bf12c21f3ac1adb68275db986e04a327aa2 (patch)
treeacc42ec15338973c22df05832c295d7a9bc7e36d
parent6ce85091c1d5e2ea26e264ef9a1da73038ff01e7 (diff)
downloadATCD-8fb76bf12c21f3ac1adb68275db986e04a327aa2.tar.gz
ChangeLogTag: Fri Jun 10 12:41:00 UTC 2011 Simon Massey <sma at prismtech dot com>
-rw-r--r--TAO/ChangeLog32
-rw-r--r--TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp15
-rw-r--r--TAO/tests/MT_NoUpcall_Client_Leader/chatter.h5
-rw-r--r--TAO/tests/MT_NoUpcall_Client_Leader/client.cpp66
-rw-r--r--TAO/tests/MT_NoUpcall_Client_Leader/police.cpp10
-rwxr-xr-xTAO/tests/MT_NoUpcall_Client_Leader/run_test.pl29
-rw-r--r--TAO/tests/MT_NoUpcall_Client_Leader/server.cpp36
7 files changed, 119 insertions, 74 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 86c330219a7..3cd6bedb096 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,35 @@
+Fri Jun 10 12:41:00 UTC 2011 Simon Massey <sma at prismtech dot com>
+
+ * tests/MT_NoUpcall_Client_Leader/run_test.pl:
+
+ This test wasn't capable of exiting with an error, it was
+ always successful even if the test failed.
+
+ * tests/MT_NoUpcall_Client_Leader/client.cpp:
+ * tests/MT_NoUpcall_Client_Leader/server.cpp:
+
+ The mutex needed to be locked prior to worker thread creation
+ and the stop_condition.wait condition, then released after,
+ otherwise worker threads can signal prior to the server/client
+ being ready to deal with the event. Client needed to
+ pause before the issuing the shutdown request to the server
+ so as to allow it to finish its own worker thread.
+
+ * tests/MT_NoUpcall_Client_Leader/police.cpp:
+
+ The stat test in the loop was occationally detecting the creation
+ of the ior file before the contents had been written. Moving
+ the sleep after the stat and before the test allows the contents to
+ be output before allowing the client/server to use the ior it
+ has just detected.
+
+ * tests/MT_NoUpcall_Client_Leader/chatter.cpp:
+ * tests/MT_NoUpcall_Client_Leader/chatter.h:
+
+ Need to mutex control access to the two nrequests_ and nreplies_
+ counts, as the client has two concurrent worker threads competing
+ to update them, these counts also need to be volitile.
+
Thu Jun 9 19:38:48 UTC 2011 Jeff Parsons <j.parsons@vanderbilt.edu>
* TAO_IDL/be/be_helper.cpp:
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp
index 6a9248bda6f..b29c1e9bfc1 100644
--- a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp
+++ b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp
@@ -28,7 +28,7 @@ Chatter::nrequests (void)
int
Chatter::svc (void)
{
- long nrq = nrequests ();
+ long nrq = -1;
try
{
//sleep(1);
@@ -43,12 +43,19 @@ Chatter::svc (void)
ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", ior_), -1);
// make call on server
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, request_reply_count_mutex_, -1);
+ nrq= nrequests ();
+ nrequests_++;
+ }
ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] started for %s\n", nrq, ior_));
- nrequests_++;
intf_var->ping();
- nreplies_++;
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, request_reply_count_mutex_, -1);
+ nreplies_++;
+ }
- ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] completed for %s\n", nrq, ior_));
+ ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d,%d,%d] completed for %s\n", nrq, nrequests_, nreplies_, ior_));
cond_.signal();
return 0;
}
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h
index 8e5a313a0fa..576a4419ea8 100644
--- a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h
+++ b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h
@@ -17,10 +17,11 @@ public:
long nrequests (void);
long nreplies (void);
public:
- long nrequests_;
- long nreplies_;
+ volatile long nrequests_;
+ volatile long nreplies_;
private:
const ACE_TCHAR* ior_;
ACE_Condition<ACE_Mutex>& cond_;
+ TAO_SYNCH_MUTEX request_reply_count_mutex_;
};
#endif /* CHATTER_H */
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp
index fafa60c74d1..9d2dde85f95 100644
--- a/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp
+++ b/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp
@@ -7,6 +7,7 @@
#include "ace/SString.h"
#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
const ACE_TCHAR *ior_output_file = ACE_TEXT ("client.ior");
int nr_threads = 1;
@@ -107,54 +108,57 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
ACE_Mutex mutex;
ACE_Condition<ACE_Mutex> stop_condition (mutex);
+ {
+ ACE_GUARD_RETURN (ACE_Mutex, guard, mutex, -1);
- const ACE_TCHAR* serverior = ACE_TEXT("file://server.ior");
- Chatter worker2 (orb_.in (), serverior, stop_condition);
+ 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);
+ 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);
+ ACE_OS::sleep (8);
- 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);
+ // Kill the peer
+ {
+ CORBA::Object_var rawObject = orb_->string_to_object( serverior);
- Test_Idl::SharedIntf_var intf_var =
+ 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);
+ 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));
+ // make call on server
+ ACE_DEBUG((LM_INFO,"(%P|%t) farewell START for %s\n", serverior));
- intf_var->farewell();
+ intf_var->farewell();
- ACE_DEBUG((LM_INFO,"(%P|%t) farewell COMPLETE for %s\n", serverior));
- }
+ ACE_DEBUG((LM_INFO,"(%P|%t) farewell COMPLETE for %s\n", serverior));
+ }
+ ACE_OS::sleep (8);
- ACE_DEBUG((LM_INFO,"(%P|%t) END OF CLIENT TEST\n"));
+ ACE_DEBUG((LM_INFO,"(%P|%t) END OF CLIENT TEST\n"));
- orb_.in()->shutdown ();
+ orb_.in()->shutdown ();
- worker.thr_mgr()->wait ();
+ worker.thr_mgr()->wait ();
- root_poa->destroy(1,1);
+ root_poa->destroy(1,1);
- orb_->destroy();
+ orb_->destroy();
- ACE_DEBUG((LM_INFO,"(%P|%t) Client Test %C\n",
- (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed"));
+ ACE_DEBUG((LM_INFO,"(%P|%t) Client Test %C\n",
+ (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed"));
- result = (worker2.nrequests_ == worker2.nreplies_)? 0 : -1;
+ result = (worker2.nrequests_ == worker2.nreplies_)? 0 : -1;
+ }
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp
index 17eb4ea649e..852ccd952f1 100644
--- a/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp
+++ b/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp
@@ -5,9 +5,11 @@
void poll (const char* filename)
{
- ACE_stat st;
- for (int r=1; r != 0; r = ACE_OS::stat (filename, &st))
+ int r;
+ do
{
- ACE_OS::sleep (1);
- }
+ ACE_stat st;
+ r = ACE_OS::stat (filename, &st);
+ ACE_OS::sleep (1); // Allows time between waiting scans and for contents to be written
+ } while (r != 0);
}
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl b/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl
index d64c2393165..9b33af7e783 100755
--- a/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl
+++ b/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl
@@ -8,6 +8,8 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;
+my $exit_status = 0;
+
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";
@@ -15,7 +17,6 @@ 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';
@@ -33,14 +34,11 @@ $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";
@@ -49,9 +47,7 @@ if ($server->WaitForFileTimed ($server_iorbase,
}
$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);
@@ -66,26 +62,27 @@ if ($client->WaitForFileTimed ($client_iorbase,
}
print "INFO: Awaiting server ...\n";
-
-$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 30);
-
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 60);
if ($server_status != 0) {
print STDERR "ERROR: server returned $server_status\n";
- $status = 1;
+ $exit_status = 1;
}
print "INFO: Awaiting client ...\n";
-
-$client_status = $CL->WaitKill ($client->ProcessStartWaitInterval());
-
+$client_status = $CL->WaitKill ($client->ProcessStartWaitInterval() + 10);
if ($client_status != 0) {
print STDERR "ERROR: client returned $client_status\n";
- $status = 1;
+ $exit_status = 1;
}
$server->DeleteFile($server_iorfile);
$client->DeleteFile($client_iorfile);
-print "INFO: Test succeeded\n";
-exit 0;
+if ($exit_status == 0) {
+ print "INFO: Test succeeded\n";
+}
+else {
+ print "INFO: Test Failed!\n";
+}
+exit $exit_status;
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp
index b8e2e942dbc..e2479ce29fd 100644
--- a/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp
+++ b/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp
@@ -109,29 +109,31 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[])
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);
- }
+ ACE_GUARD_RETURN (ACE_Mutex, guard, mutex, -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);
+ 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);
+ }
- worker.thr_mgr()->wait ();
+ 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);
- root_poa->destroy(1, 1);
+ worker.thr_mgr()->wait ();
- orb_->destroy();
+ root_poa->destroy(1, 1);
- ACE_DEBUG((LM_INFO,"(%P|%t) Server Test %C\n",
- (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed"));
- result = (worker2.nrequests() == worker2.nreplies())? 0 : -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)
{