1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
7 use lib
"$ENV{ACE_ROOT}/bin";
8 use PerlACE
::TestTarget
;
19 my $server = PerlACE
::TestTarget
::create_target
(1) || die "Create target 1 failed\n";
20 my $client1 = PerlACE
::TestTarget
::create_target
(2) || die "Create target 2 failed\n";
21 my $client2 = PerlACE
::TestTarget
::create_target
(3) || die "Create target 3 failed\n";
22 my $client3 = PerlACE
::TestTarget
::create_target
(4) || die "Create target 4 failed\n";
23 my $client4 = PerlACE
::TestTarget
::create_target
(5) || die "Create target 5 failed\n";
25 my $iorbase = "server.ior";
26 my $svcbase = "server$PerlACE::svcconf_ext";
27 my $server_iorfile = $server->LocalFile ($iorbase);
28 my $server_svcfile = $server->LocalFile ($svcbase);
29 my $client1_iorfile = $client1->LocalFile ($iorbase);
30 my $client2_iorfile = $client2->LocalFile ($iorbase);
31 my $client3_iorfile = $client3->LocalFile ($iorbase);
32 my $client4_iorfile = $client4->LocalFile ($iorbase);
33 $server->DeleteFile($iorbase);
34 $client1->DeleteFile($iorbase);
35 $client2->DeleteFile($iorbase);
36 $client3->DeleteFile($iorbase);
37 $client4->DeleteFile($iorbase);
39 my $hostname = $server->HostName ();
41 # Copy configuration file first
42 if ($server->PutFile ($svcbase) == -1) {
43 print STDERR
"ERROR: cannot set file <$server_svcfile>\n";
47 $SV = $server->CreateProcess ("MessengerServer",
48 "-ORBdebuglevel $debug_level " .
49 "-ORBSvcConf $server_svcfile " .
50 "-ORBListenEndpoints iiop://$hostname " .
51 "-o $server_iorfile");
52 $CL1 = $client1->CreateProcess ("MessengerClient", "-k file://$client1_iorfile");
53 $CL2 = $client2->CreateProcess ("MessengerClient", "-k file://$client2_iorfile");
54 $CL3 = $client3->CreateProcess ("MessengerClient", "-k file://$client3_iorfile");
55 $CL4 = $client4->CreateProcess ("MessengerClient", "-k file://$client4_iorfile");
57 print STDOUT
"Starting MessengerServer\n";
58 $server_status = $SV->Spawn ();
60 if ($server_status != 0) {
61 print STDERR
"ERROR: server returned $server_status\n";
65 if ($server->WaitForFileTimed ($iorbase,
66 $server->ProcessStartWaitInterval()) == -1) {
67 print STDERR
"ERROR: cannot find file <$server_iorfile>\n";
68 $SV->Kill (); $SV->TimedWait (1);
72 if ($server->GetFile ($iorbase) == -1) {
73 print STDERR
"ERROR: cannot retrieve file <$server_iorfile>\n";
74 $SV->Kill (); $SV->TimedWait (1);
77 if ($client1->PutFile ($iorbase) == -1) {
78 print STDERR
"ERROR: cannot set file <$client1_iorfile>\n";
79 $SV->Kill (); $SV->TimedWait (1);
82 if ($client2->PutFile ($iorbase) == -1) {
83 print STDERR
"ERROR: cannot set file <$client2_iorfile>\n";
84 $SV->Kill (); $SV->TimedWait (1);
87 if ($client3->PutFile ($iorbase) == -1) {
88 print STDERR
"ERROR: cannot set file <$client3_iorfile>\n";
89 $SV->Kill (); $SV->TimedWait (1);
92 if ($client4->PutFile ($iorbase) == -1) {
93 print STDERR
"ERROR: cannot set file <$client4_iorfile>\n";
94 $SV->Kill (); $SV->TimedWait (1);
98 print STDOUT
"\n\nStarting 4 MessengerClients.\n";
99 print STDOUT
"Each client should get a new connection ".
100 "and its own thread in the server.\n\n";
102 $client_status = $CL1->Spawn ();
104 if ($client_status != 0) {
105 print STDERR
"ERROR: client returned $client_status\n";
106 $SV->Kill (); $SV->TimedWait (1);
110 $client_status = $CL2->Spawn ();
112 if ($client_status != 0) {
113 print STDERR
"ERROR: client returned $client_status\n";
114 $SV->Kill (); $SV->TimedWait (1);
115 $CL1->Kill (); $CL1->TimedWait (1);
119 $client_status = $CL3->Spawn ();
121 if ($client_status != 0) {
122 print STDERR
"ERROR: client returned $client_status\n";
123 $SV->Kill (); $SV->TimedWait (1);
124 $CL1->Kill (); $CL1->TimedWait (1);
125 $CL2->Kill (); $CL2->TimedWait (1);
129 $client_status = $CL4->Spawn ();
131 if ($client_status != 0) {
132 print STDERR
"ERROR: client returned $client_status\n";
133 $SV->Kill (); $SV->TimedWait (1);
134 $CL1->Kill (); $CL1->TimedWait (1);
135 $CL2->Kill (); $CL2->TimedWait (1);
136 $CL3->Kill (); $CL3->TimedWait (1);
140 $client_status = $CL1->WaitKill ($client1->ProcessStopWaitInterval());
142 if ($client_status != 0) {
143 print STDERR
"ERROR: client returned $client_status\n";
147 $client_status = $CL2->WaitKill ($client2->ProcessStopWaitInterval());
149 if ($client_status != 0) {
150 print STDERR
"ERROR: client returned $client_status\n";
154 $client_status = $CL3->WaitKill ($client3->ProcessStopWaitInterval());
156 if ($client_status != 0) {
157 print STDERR
"ERROR: client returned $client_status\n";
161 $client_status = $CL4->WaitKill ($client4->ProcessStopWaitInterval());
163 if ($client_status != 0) {
164 print STDERR
"ERROR: client returned $client_status\n";
170 $server->DeleteFile($iorbase);
171 $client1->DeleteFile($iorbase);
172 $client2->DeleteFile($iorbase);
173 $client3->DeleteFile($iorbase);
174 $client4->DeleteFile($iorbase);