File: | pr/Linux4.19_x86_64_gcc_glibc_PTH_64_DBG.OBJ/pr/tests/../../../pr/tests/server_test.c |
Warning: | line 438, column 9 Value stored to 'rv' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | |
6 | /*********************************************************************** |
7 | ** |
8 | ** This server simulates a server running in loopback mode. |
9 | ** |
10 | ** The idea is that a single server is created. The server initially creates |
11 | ** a number of worker threads. Then, with the server running, a number of |
12 | ** clients are created which start requesting service from the server. |
13 | ** |
14 | ** |
15 | ** Modification History: |
16 | ** 19-May-97 AGarcia- Converted the test to accomodate the debug_mode flag. |
17 | ** The debug mode will print all of the printfs associated with this test. |
18 | ** The regress mode will be the default mode. Since the regress tool limits |
19 | ** the output to a one line status:PASS or FAIL,all of the printf statements |
20 | ** have been handled with an if (debug_mode) statement. |
21 | ***********************************************************************/ |
22 | |
23 | /*********************************************************************** |
24 | ** Includes |
25 | ***********************************************************************/ |
26 | /* Used to get the command line option */ |
27 | #include "plgetopt.h" |
28 | |
29 | #include "nspr.h" |
30 | #include "pprthred.h" |
31 | |
32 | #include <string.h> |
33 | |
34 | #define PORT15004 15004 |
35 | #define THREAD_STACKSIZE0 0 |
36 | |
37 | #define PASS0 0 |
38 | #define FAIL1 1 |
39 | static int debug_mode = 0; |
40 | static int failed_already = 0; |
41 | |
42 | static int _iterations = 1000; |
43 | static int _clients = 1; |
44 | static int _client_data = 250; |
45 | static int _server_data = (8*1024); |
46 | |
47 | static PRThreadScope ServerScope, ClientScope; |
48 | |
49 | #define SERVER"Server" "Server" |
50 | #define MAIN"Main" "Main" |
51 | |
52 | #define SERVER_STATE_STARTUP0 0 |
53 | #define SERVER_STATE_READY1 1 |
54 | #define SERVER_STATE_DYING2 2 |
55 | #define SERVER_STATE_DEAD4 4 |
56 | int ServerState; |
57 | PRLock *ServerStateCVLock; |
58 | PRCondVar *ServerStateCV; |
59 | |
60 | #undef DEBUGPRINTS |
61 | #ifdef DEBUGPRINTS |
62 | #define DPRINTF printf |
63 | #else |
64 | #define DPRINTF |
65 | #endif |
66 | |
67 | |
68 | /*********************************************************************** |
69 | ** PRIVATE FUNCTION: Test_Result |
70 | ** DESCRIPTION: Used in conjunction with the regress tool, prints out the |
71 | ** status of the test case. |
72 | ** INPUTS: PASS/FAIL |
73 | ** OUTPUTS: None |
74 | ** RETURN: None |
75 | ** SIDE EFFECTS: |
76 | ** |
77 | ** RESTRICTIONS: |
78 | ** None |
79 | ** MEMORY: NA |
80 | ** ALGORITHM: Determine what the status is and print accordingly. |
81 | ** |
82 | ***********************************************************************/ |
83 | |
84 | |
85 | static void Test_Result (int result) |
86 | { |
87 | switch (result) |
88 | { |
89 | case PASS0: |
90 | printf ("PASS\n"); |
91 | break; |
92 | case FAIL1: |
93 | printf ("FAIL\n"); |
94 | failed_already = 1; |
95 | break; |
96 | default: |
97 | break; |
98 | } |
99 | } |
100 | |
101 | static void do_work(void); |
102 | |
103 | /* --- Server state functions --------------------------------------------- */ |
104 | void |
105 | SetServerState(char *waiter, PRInt32 state) |
106 | { |
107 | PR_Lock(ServerStateCVLock); |
108 | ServerState = state; |
109 | PR_NotifyCondVar(ServerStateCV); |
110 | |
111 | if (debug_mode) { |
112 | DPRINTF("\t%s changed state to %d\n", waiter, state); |
113 | } |
114 | |
115 | PR_Unlock(ServerStateCVLock); |
116 | } |
117 | |
118 | int |
119 | WaitServerState(char *waiter, PRInt32 state) |
120 | { |
121 | PRInt32 rv; |
122 | |
123 | PR_Lock(ServerStateCVLock); |
124 | |
125 | if (debug_mode) { |
126 | DPRINTF("\t%s waiting for state %d\n", waiter, state); |
127 | } |
128 | |
129 | while(!(ServerState & state)) { |
130 | PR_WaitCondVar(ServerStateCV, PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
131 | } |
132 | rv = ServerState; |
133 | |
134 | if (debug_mode) DPRINTF("\t%s resuming from wait for state %d; state now %d\n", |
135 | waiter, state, ServerState); |
136 | PR_Unlock(ServerStateCVLock); |
137 | |
138 | return rv; |
139 | } |
140 | |
141 | /* --- Server Functions ------------------------------------------- */ |
142 | |
143 | PRLock *workerThreadsLock; |
144 | PRInt32 workerThreads; |
145 | PRInt32 workerThreadsBusy; |
146 | |
147 | void |
148 | WorkerThreadFunc(void *_listenSock) |
149 | { |
150 | PRFileDesc *listenSock = (PRFileDesc *)_listenSock; |
151 | PRInt32 bytesRead; |
152 | PRInt32 bytesWritten; |
153 | char *dataBuf; |
154 | char *sendBuf; |
155 | |
156 | if (debug_mode) DPRINTF("\tServer buffer is %d bytes; %d data, %d netaddrs\n", |
157 | _client_data+(2*sizeof(PRNetAddr))+32, _client_data, (2*sizeof(PRNetAddr))+32); |
158 | dataBuf = (char *)PR_MALLOC(_client_data + 2*sizeof(PRNetAddr) + 32)(PR_Malloc((_client_data + 2*sizeof(PRNetAddr) + 32))); |
159 | if (!dataBuf) |
160 | if (debug_mode) { |
161 | printf("\tServer could not malloc space!?\n"); |
162 | } |
163 | sendBuf = (char *)PR_MALLOC(_server_data *sizeof(char))(PR_Malloc((_server_data *sizeof(char)))); |
164 | if (!sendBuf) |
165 | if (debug_mode) { |
166 | printf("\tServer could not malloc space!?\n"); |
167 | } |
168 | |
169 | if (debug_mode) { |
170 | DPRINTF("\tServer worker thread running\n"); |
171 | } |
172 | |
173 | while(1) { |
174 | PRInt32 bytesToRead = _client_data; |
175 | PRInt32 bytesToWrite = _server_data; |
176 | PRFileDesc *newSock; |
177 | PRNetAddr *rAddr; |
178 | PRInt32 loops = 0; |
179 | |
180 | loops++; |
181 | |
182 | if (debug_mode) { |
183 | DPRINTF("\tServer thread going into accept\n"); |
184 | } |
185 | |
186 | bytesRead = PR_AcceptRead(listenSock, |
187 | &newSock, |
188 | &rAddr, |
189 | dataBuf, |
190 | bytesToRead, |
191 | PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
192 | |
193 | if (bytesRead < 0) { |
194 | if (debug_mode) { |
195 | printf("\tServer error in accept (%d)\n", bytesRead); |
196 | } |
197 | continue; |
198 | } |
199 | |
200 | if (debug_mode) { |
201 | DPRINTF("\tServer accepted connection (%d bytes)\n", bytesRead); |
202 | } |
203 | |
204 | PR_AtomicIncrement(&workerThreadsBusy); |
205 | if (workerThreadsBusy == workerThreads) { |
206 | PR_Lock(workerThreadsLock); |
207 | if (workerThreadsBusy == workerThreads) { |
208 | PRThread *WorkerThread; |
209 | |
210 | WorkerThread = PR_CreateThread( |
211 | PR_SYSTEM_THREAD, |
212 | WorkerThreadFunc, |
213 | listenSock, |
214 | PR_PRIORITY_NORMAL, |
215 | ServerScope, |
216 | PR_UNJOINABLE_THREAD, |
217 | THREAD_STACKSIZE0); |
218 | |
219 | if (!WorkerThread) { |
220 | if (debug_mode) { |
221 | printf("Error creating client thread %d\n", workerThreads); |
222 | } |
223 | } else { |
224 | PR_AtomicIncrement(&workerThreads); |
225 | if (debug_mode) { |
226 | DPRINTF("\tServer creates worker (%d)\n", workerThreads); |
227 | } |
228 | } |
229 | } |
230 | PR_Unlock(workerThreadsLock); |
231 | } |
232 | |
233 | bytesToRead -= bytesRead; |
234 | while (bytesToRead) { |
235 | bytesRead = PR_Recv(newSock, |
236 | dataBuf, |
237 | bytesToRead, |
238 | 0, |
239 | PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
240 | if (bytesRead < 0) { |
241 | if (debug_mode) { |
242 | printf("\tServer error receiving data (%d)\n", bytesRead); |
243 | } |
244 | continue; |
245 | } |
246 | if (debug_mode) { |
247 | DPRINTF("\tServer received %d bytes\n", bytesRead); |
248 | } |
249 | } |
250 | |
251 | bytesWritten = PR_Send(newSock, |
252 | sendBuf, |
253 | bytesToWrite, |
254 | 0, |
255 | PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
256 | if (bytesWritten != _server_data) { |
257 | if (debug_mode) printf("\tError sending data to client (%d, %d)\n", |
258 | bytesWritten, PR_GetOSError()); |
259 | } else { |
260 | if (debug_mode) { |
261 | DPRINTF("\tServer sent %d bytes\n", bytesWritten); |
262 | } |
263 | } |
264 | |
265 | PR_Close(newSock); |
266 | PR_AtomicDecrement(&workerThreadsBusy); |
267 | } |
268 | } |
269 | |
270 | PRFileDesc * |
271 | ServerSetup(void) |
272 | { |
273 | PRFileDesc *listenSocket; |
274 | PRSocketOptionData sockOpt; |
275 | PRNetAddr serverAddr; |
276 | PRThread *WorkerThread; |
277 | |
278 | if ((listenSocket = PR_NewTCPSocket()) == NULL((void*)0)) { |
279 | if (debug_mode) { |
280 | printf("\tServer error creating listen socket\n"); |
281 | } |
282 | else { |
283 | Test_Result(FAIL1); |
284 | } |
285 | return NULL((void*)0); |
286 | } |
287 | |
288 | sockOpt.option = PR_SockOpt_Reuseaddr; |
289 | sockOpt.value.reuse_addr = PR_TRUE1; |
290 | if (PR_SetSocketOption(listenSocket, &sockOpt) != PR_SUCCESS) { |
291 | if (debug_mode) printf("\tServer error setting socket option: OS error %d\n", |
292 | PR_GetOSError()); |
293 | else { |
294 | Test_Result(FAIL1); |
295 | } |
296 | PR_Close(listenSocket); |
297 | return NULL((void*)0); |
298 | } |
299 | |
300 | memset(&serverAddr, 0, sizeof(PRNetAddr)); |
301 | serverAddr.inet.family = PR_AF_INET2; |
302 | serverAddr.inet.port = PR_htons(PORT15004); |
303 | serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY((in_addr_t) 0x00000000)); |
304 | |
305 | if (PR_Bind(listenSocket, &serverAddr) != PR_SUCCESS) { |
306 | if (debug_mode) printf("\tServer error binding to server address: OS error %d\n", |
307 | PR_GetOSError()); |
308 | else { |
309 | Test_Result(FAIL1); |
310 | } |
311 | PR_Close(listenSocket); |
312 | return NULL((void*)0); |
313 | } |
314 | |
315 | if (PR_Listen(listenSocket, 128) != PR_SUCCESS) { |
316 | if (debug_mode) { |
317 | printf("\tServer error listening to server socket\n"); |
318 | } |
319 | else { |
320 | Test_Result(FAIL1); |
321 | } |
322 | PR_Close(listenSocket); |
323 | |
324 | return NULL((void*)0); |
325 | } |
326 | |
327 | /* Create Clients */ |
328 | workerThreads = 0; |
329 | workerThreadsBusy = 0; |
330 | |
331 | workerThreadsLock = PR_NewLock(); |
332 | |
333 | WorkerThread = PR_CreateThread( |
334 | PR_SYSTEM_THREAD, |
335 | WorkerThreadFunc, |
336 | listenSocket, |
337 | PR_PRIORITY_NORMAL, |
338 | ServerScope, |
339 | PR_UNJOINABLE_THREAD, |
340 | THREAD_STACKSIZE0); |
341 | |
342 | if (!WorkerThread) { |
343 | if (debug_mode) { |
344 | printf("error creating working thread\n"); |
345 | } |
346 | PR_Close(listenSocket); |
347 | return NULL((void*)0); |
348 | } |
349 | PR_AtomicIncrement(&workerThreads); |
350 | if (debug_mode) { |
351 | DPRINTF("\tServer created primordial worker thread\n"); |
352 | } |
353 | |
354 | return listenSocket; |
355 | } |
356 | |
357 | /* The main server loop */ |
358 | void |
359 | ServerThreadFunc(void *unused) |
360 | { |
361 | PRFileDesc *listenSocket; |
362 | |
363 | /* Do setup */ |
364 | listenSocket = ServerSetup(); |
365 | |
366 | if (!listenSocket) { |
367 | SetServerState(SERVER"Server", SERVER_STATE_DEAD4); |
368 | } else { |
369 | |
370 | if (debug_mode) { |
371 | DPRINTF("\tServer up\n"); |
372 | } |
373 | |
374 | /* Tell clients they can start now. */ |
375 | SetServerState(SERVER"Server", SERVER_STATE_READY1); |
376 | |
377 | /* Now wait for server death signal */ |
378 | WaitServerState(SERVER"Server", SERVER_STATE_DYING2); |
379 | |
380 | /* Cleanup */ |
381 | SetServerState(SERVER"Server", SERVER_STATE_DEAD4); |
382 | } |
383 | } |
384 | |
385 | /* --- Client Functions ------------------------------------------- */ |
386 | |
387 | PRInt32 numRequests; |
388 | PRInt32 numClients; |
389 | PRMonitor *clientMonitor; |
390 | |
391 | void |
392 | ClientThreadFunc(void *unused) |
393 | { |
394 | PRNetAddr serverAddr; |
395 | PRFileDesc *clientSocket; |
396 | char *sendBuf; |
397 | char *recvBuf; |
398 | PRInt32 rv; |
399 | PRInt32 bytesNeeded; |
400 | |
401 | sendBuf = (char *)PR_MALLOC(_client_data * sizeof(char))(PR_Malloc((_client_data * sizeof(char)))); |
402 | if (!sendBuf) |
403 | if (debug_mode) { |
404 | printf("\tClient could not malloc space!?\n"); |
405 | } |
406 | recvBuf = (char *)PR_MALLOC(_server_data * sizeof(char))(PR_Malloc((_server_data * sizeof(char)))); |
407 | if (!recvBuf) |
408 | if (debug_mode) { |
409 | printf("\tClient could not malloc space!?\n"); |
410 | } |
411 | |
412 | memset(&serverAddr, 0, sizeof(PRNetAddr)); |
413 | serverAddr.inet.family = PR_AF_INET2; |
414 | serverAddr.inet.port = PR_htons(PORT15004); |
415 | serverAddr.inet.ip = PR_htonl(PR_INADDR_LOOPBACK((in_addr_t) 0x7f000001)); |
416 | |
417 | while(numRequests > 0) { |
418 | |
419 | if ( (numRequests % 10) == 0 ) |
420 | if (debug_mode) { |
421 | printf("."); |
422 | } |
423 | if (debug_mode) { |
424 | DPRINTF("\tClient starting request %d\n", numRequests); |
425 | } |
426 | |
427 | clientSocket = PR_NewTCPSocket(); |
428 | if (!clientSocket) { |
429 | if (debug_mode) printf("Client error creating socket: OS error %d\n", |
430 | PR_GetOSError()); |
431 | continue; |
432 | } |
433 | |
434 | if (debug_mode) { |
435 | DPRINTF("\tClient connecting\n"); |
436 | } |
437 | |
438 | rv = PR_Connect(clientSocket, |
Value stored to 'rv' is never read | |
439 | &serverAddr, |
440 | PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
441 | if (!clientSocket) { |
442 | if (debug_mode) { |
443 | printf("\tClient error connecting\n"); |
444 | } |
445 | continue; |
446 | } |
447 | |
448 | if (debug_mode) { |
449 | DPRINTF("\tClient connected\n"); |
450 | } |
451 | |
452 | rv = PR_Send(clientSocket, |
453 | sendBuf, |
454 | _client_data, |
455 | 0, |
456 | PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
457 | if (rv != _client_data) { |
458 | if (debug_mode) { |
459 | printf("Client error sending data (%d)\n", rv); |
460 | } |
461 | PR_Close(clientSocket); |
462 | continue; |
463 | } |
464 | |
465 | if (debug_mode) { |
466 | DPRINTF("\tClient sent %d bytes\n", rv); |
467 | } |
468 | |
469 | bytesNeeded = _server_data; |
470 | while(bytesNeeded) { |
471 | rv = PR_Recv(clientSocket, |
472 | recvBuf, |
473 | bytesNeeded, |
474 | 0, |
475 | PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
476 | if (rv <= 0) { |
477 | if (debug_mode) printf("Client error receiving data (%d) (%d/%d)\n", |
478 | rv, (_server_data - bytesNeeded), _server_data); |
479 | break; |
480 | } |
481 | if (debug_mode) { |
482 | DPRINTF("\tClient received %d bytes; need %d more\n", rv, bytesNeeded - rv); |
483 | } |
484 | bytesNeeded -= rv; |
485 | } |
486 | |
487 | PR_Close(clientSocket); |
488 | |
489 | PR_AtomicDecrement(&numRequests); |
490 | } |
491 | |
492 | PR_EnterMonitor(clientMonitor); |
493 | --numClients; |
494 | PR_Notify(clientMonitor); |
495 | PR_ExitMonitor(clientMonitor); |
496 | |
497 | PR_DELETE(sendBuf){ PR_Free(sendBuf); (sendBuf) = ((void*)0); }; |
498 | PR_DELETE(recvBuf){ PR_Free(recvBuf); (recvBuf) = ((void*)0); }; |
499 | } |
500 | |
501 | void |
502 | RunClients(void) |
503 | { |
504 | PRInt32 index; |
505 | |
506 | numRequests = _iterations; |
507 | numClients = _clients; |
508 | clientMonitor = PR_NewMonitor(); |
509 | |
510 | for (index=0; index<_clients; index++) { |
511 | PRThread *clientThread; |
512 | |
513 | |
514 | clientThread = PR_CreateThread( |
515 | PR_USER_THREAD, |
516 | ClientThreadFunc, |
517 | NULL((void*)0), |
518 | PR_PRIORITY_NORMAL, |
519 | ClientScope, |
520 | PR_UNJOINABLE_THREAD, |
521 | THREAD_STACKSIZE0); |
522 | |
523 | if (!clientThread) { |
524 | if (debug_mode) { |
525 | printf("\terror creating client thread %d\n", index); |
526 | } |
527 | } else if (debug_mode) { |
528 | DPRINTF("\tMain created client %d/%d\n", index+1, _clients); |
529 | } |
530 | |
531 | } |
532 | |
533 | PR_EnterMonitor(clientMonitor); |
534 | while(numClients) { |
535 | PR_Wait(clientMonitor, PR_INTERVAL_NO_TIMEOUT0xffffffffUL); |
536 | } |
537 | PR_ExitMonitor(clientMonitor); |
538 | } |
539 | |
540 | /* --- Main Function ---------------------------------------------- */ |
541 | |
542 | static |
543 | void do_work() |
544 | { |
545 | PRThread *ServerThread; |
546 | PRInt32 state; |
547 | |
548 | SetServerState(MAIN"Main", SERVER_STATE_STARTUP0); |
549 | ServerThread = PR_CreateThread( |
550 | PR_USER_THREAD, |
551 | ServerThreadFunc, |
552 | NULL((void*)0), |
553 | PR_PRIORITY_NORMAL, |
554 | ServerScope, |
555 | PR_JOINABLE_THREAD, |
556 | THREAD_STACKSIZE0); |
557 | if (!ServerThread) { |
558 | if (debug_mode) { |
559 | printf("error creating main server thread\n"); |
560 | } |
561 | return; |
562 | } |
563 | |
564 | /* Wait for server to be ready */ |
565 | state = WaitServerState(MAIN"Main", SERVER_STATE_READY1|SERVER_STATE_DEAD4); |
566 | |
567 | if (!(state & SERVER_STATE_DEAD4)) { |
568 | /* Run Test Clients */ |
569 | RunClients(); |
570 | |
571 | /* Send death signal to server */ |
572 | SetServerState(MAIN"Main", SERVER_STATE_DYING2); |
573 | } |
574 | |
575 | PR_JoinThread(ServerThread); |
576 | } |
577 | |
578 | static void do_workUU(void) |
579 | { |
580 | ServerScope = PR_LOCAL_THREAD; |
581 | ClientScope = PR_LOCAL_THREAD; |
582 | do_work(); |
583 | } |
584 | |
585 | static void do_workUK(void) |
586 | { |
587 | ServerScope = PR_LOCAL_THREAD; |
588 | ClientScope = PR_GLOBAL_THREAD; |
589 | do_work(); |
590 | } |
591 | |
592 | static void do_workKU(void) |
593 | { |
594 | ServerScope = PR_GLOBAL_THREAD; |
595 | ClientScope = PR_LOCAL_THREAD; |
596 | do_work(); |
597 | } |
598 | |
599 | static void do_workKK(void) |
600 | { |
601 | ServerScope = PR_GLOBAL_THREAD; |
602 | ClientScope = PR_GLOBAL_THREAD; |
603 | do_work(); |
604 | } |
605 | |
606 | |
607 | static void Measure(void (*func)(void), const char *msg) |
608 | { |
609 | PRIntervalTime start, stop; |
610 | double d; |
611 | |
612 | start = PR_IntervalNow(); |
613 | (*func)(); |
614 | stop = PR_IntervalNow(); |
615 | |
616 | d = (double)PR_IntervalToMicroseconds(stop - start); |
617 | |
618 | if (debug_mode) { |
619 | printf("\n%40s: %6.2f usec\n", msg, d / _iterations); |
620 | } |
621 | } |
622 | |
623 | |
624 | int main(int argc, char **argv) |
625 | { |
626 | /* The command line argument: -d is used to determine if the test is being run |
627 | in debug mode. The regress tool requires only one line output:PASS or FAIL. |
628 | All of the printfs associated with this test has been handled with a if (debug_mode) |
629 | test. |
630 | Usage: test_name -d |
631 | */ |
632 | PLOptStatus os; |
633 | PLOptState *opt = PL_CreateOptState(argc, argv, "d"); |
634 | while (PL_OPT_EOL != (os = PL_GetNextOpt(opt))) |
635 | { |
636 | if (PL_OPT_BAD == os) { |
637 | continue; |
638 | } |
639 | switch (opt->option) |
640 | { |
641 | case 'd': /* debug mode */ |
642 | debug_mode = 1; |
643 | break; |
644 | default: |
645 | break; |
646 | } |
647 | } |
648 | PL_DestroyOptState(opt); |
649 | |
650 | /* main test */ |
651 | if (debug_mode) { |
652 | printf("Enter number of iterations: \n"); |
653 | scanf("%d", &_iterations); |
654 | printf("Enter number of clients : \n"); |
655 | scanf("%d", &_clients); |
656 | printf("Enter size of client data : \n"); |
657 | scanf("%d", &_client_data); |
658 | printf("Enter size of server data : \n"); |
659 | scanf("%d", &_server_data); |
660 | } |
661 | else |
662 | { |
663 | |
664 | _iterations = 10; |
665 | _clients = 1; |
666 | _client_data = 10; |
667 | _server_data = 10; |
668 | } |
669 | |
670 | if (debug_mode) { |
671 | printf("\n\n%d iterations with %d client threads.\n", |
672 | _iterations, _clients); |
673 | printf("Sending %d bytes of client data and %d bytes of server data\n", |
674 | _client_data, _server_data); |
675 | } |
676 | PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); |
677 | PR_STDIO_INIT(); |
678 | |
679 | ServerStateCVLock = PR_NewLock(); |
680 | ServerStateCV = PR_NewCondVar(ServerStateCVLock); |
681 | |
682 | Measure(do_workUU, "server loop user/user"); |
683 | #if 0 |
684 | Measure(do_workUK, "server loop user/kernel"); |
685 | Measure(do_workKU, "server loop kernel/user"); |
686 | Measure(do_workKK, "server loop kernel/kernel"); |
687 | #endif |
688 | |
689 | PR_Cleanup(); |
690 | |
691 | return failed_already; |
692 | } |