2 * Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution
16 * at such time that OpenAFS documentation is written.
18 * 3. Neither the name of the Institute nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <afsconfig.h>
38 nn * We are using getopt since we want it to be possible to link to
42 #include <afsconfig.h>
43 #include <afs/param.h>
46 #ifdef HAVE_SYS_FILE_H
53 #include <rx/rx_null.h>
54 #include <rx/rx_globals.h>
55 #include <rx/rx_packet.h>
57 #ifdef AFS_PTHREAD_ENV
59 #define MAX_THREADS 128
62 #define DEFAULT_PORT 7009 /* To match tcpdump */
63 #define DEFAULT_HOST "127.0.0.1"
64 #define DEFAULT_BYTES 1024 * 1024
65 #define RXPERF_BUFSIZE 512 * 1024
67 enum { RX_PERF_VERSION = 3 };
68 enum { RX_SERVER_ID = 147 };
69 enum { RX_PERF_UNKNOWN = -1,
76 enum { RXPERF_MAGIC_COOKIE = 0x4711 };
83 #define DBFPRINT(x) do { printf x ; } while(0)
91 exit(2); /* XXX profiler */
98 exit(2); /* XXX profiler */
105 static struct timeval timer_start;
106 static struct timeval timer_stop;
107 static int timer_check = 0;
113 gettimeofday(&timer_start, NULL);
121 end_and_print_timer(FILE *output, char *str, long long bytes)
123 long long start_l, stop_l;
127 assert(timer_check == 0);
128 gettimeofday(&timer_stop, NULL);
129 start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
130 stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
131 fprintf(output, "%s:\t%8llu msec", str, (stop_l - start_l) / 1000);
133 kbps = bytes * 8000.0 / (stop_l - start_l);
134 if (kbps > 1000000.0)
135 fprintf(output, "\t[%.4g Gbit/s]\n", kbps/1000000.0);
136 else if (kbps > 1000.0)
137 fprintf(output, "\t[%.4g Mbit/s]\n", kbps/1000.0);
139 fprintf(output, "\t[%.4g kbit/s]\n", kbps);
147 str2addr(const char *s)
149 struct in_addr server;
153 #define INADDR_NONE 0xffffffff
155 if (inet_addr(s) != INADDR_NONE)
157 h = gethostbyname(s);
159 memcpy(&server, h->h_addr_list[0], sizeof(server));
160 return server.s_addr;
171 get_sec(int serverp, struct rx_securityClass **sec, int *secureindex)
174 *sec = rxnull_NewServerSecurityObject();
177 *sec = rxnull_NewClientSecurityObject();
183 * process the "RPC" and return the results
186 char somebuf[RXPERF_BUFSIZE];
188 afs_int32 rxwrite_size = sizeof(somebuf);
189 afs_int32 rxread_size = sizeof(somebuf);
190 afs_int32 use_rx_readv = 0;
193 do_readbytes(struct rx_call *call, afs_int32 bytes)
195 struct iovec tiov[RX_MAXIOVECS];
206 if (size > RX_MAX_PACKET_DATA_SIZE)
207 size = RX_MAX_PACKET_DATA_SIZE;
208 code = rx_Readv(call, tiov, &tnio, RX_MAXIOVECS, size);
210 code = rx_Read(call, somebuf, size);
220 do_sendbytes(struct rx_call *call, afs_int32 bytes)
228 if (rx_Write(call, somebuf, size) != size)
237 rxperf_ExecuteRequest(struct rx_call *call)
246 afs_uint32 *readwrite;
250 DBFPRINT(("got a request\n"));
252 if (rx_Read32(call, &version) != 4) {
253 warn("rx_Read failed to read version");
257 if (htonl(RX_PERF_VERSION) != version) {
258 warnx("client has wrong version");
262 if (rx_Read32(call, &command) != 4) {
263 warnx("rx_Read failed to read command");
266 command = ntohl(command);
268 if (rx_Read32(call, &data) != 4) {
269 warnx("rx_Read failed to read size");
272 rxread_size = ntohl(data);
273 if (rxread_size > sizeof(somebuf)) {
274 warnx("rxread_size too large %d", rxread_size);
278 if (rx_Read32(call, &data) != 4) {
279 warnx("rx_Read failed to write size");
282 rxwrite_size = ntohl(data);
283 if (rxwrite_size > sizeof(somebuf)) {
284 warnx("rxwrite_size too large %d", rxwrite_size);
290 DBFPRINT(("got a send request\n"));
292 if (rx_Read32(call, &bytes) != 4) {
293 warnx("rx_Read failed to read bytes");
296 bytes = ntohl(bytes);
298 DBFPRINT(("reading(%d) ", bytes));
299 do_readbytes(call, bytes);
301 data = htonl(RXPERF_MAGIC_COOKIE);
302 if (rx_Write32(call, &data) != 4) {
303 warnx("rx_Write failed when sending back result");
306 DBFPRINT(("done\n"));
310 DBFPRINT(("got a rpc request, reading commands\n"));
312 if (rx_Read32(call, &recvb) != 4) {
313 warnx("rx_Read failed to read recvbytes");
316 recvb = ntohl(recvb);
317 if (rx_Read32(call, &sendb) != 4) {
318 warnx("rx_Read failed to read sendbytes");
321 sendb = ntohl(sendb);
323 DBFPRINT(("read(%d) ", recvb));
324 if (do_readbytes(call, recvb)) {
325 warnx("do_readbytes failed");
328 DBFPRINT(("send(%d) ", sendb));
329 if (do_sendbytes(call, sendb)) {
330 warnx("sendbytes failed");
334 DBFPRINT(("done\n"));
336 data = htonl(RXPERF_MAGIC_COOKIE);
337 if (rx_Write32(call, &data) != 4) {
338 warnx("rx_Write failed when sending back magic cookie");
344 if (rx_Read32(call, &data) != 4)
345 errx(1, "failed to read num from client");
348 readwrite = malloc(num * sizeof(afs_uint32));
349 if (readwrite == NULL)
352 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
353 num * sizeof(afs_uint32))
354 errx(1, "failed to read recvlist from client");
356 for (i = 0; i < num; i++) {
357 if (readwrite[i] == 0) {
358 DBFPRINT(("readp %d", readwrite[i]));
362 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
365 DBFPRINT(("read\n"));
366 do_readbytes(call, bytes);
368 do_sendbytes(call, bytes);
369 DBFPRINT(("send\n"));
375 DBFPRINT(("got a recv request\n"));
377 if (rx_Read32(call, &bytes) != 4) {
378 warnx("rx_Read failed to read bytes");
381 bytes = ntohl(bytes);
383 DBFPRINT(("sending(%d) ", bytes));
384 do_sendbytes(call, bytes);
386 data = htonl(RXPERF_MAGIC_COOKIE);
387 if (rx_Write32(call, &data) != 4) {
388 warnx("rx_Write failed when sending back result");
391 DBFPRINT(("done\n"));
395 warnx("client sent a unsupported command");
398 DBFPRINT(("done with command\n"));
408 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
409 int udpbufsz, int nostats, int hotthread,
410 int minprocs, int maxprocs)
412 struct rx_service *service;
413 struct rx_securityClass *secureobj;
418 if (afs_winsockInit() < 0) {
419 printf("Can't initialize winsock.\n");
425 rx_EnableHotThread();
430 rx_SetUdpBufSize(udpbufsz);
432 ret = rx_Init(htons(port));
434 errx(1, "rx_Init failed");
440 rx_SetMaxMTU(maxmtu);
443 rx_SetMaxReceiveWindow(maxwsize);
444 rx_SetMaxSendWindow(maxwsize);
448 rx_SetMinPeerTimeout(minpeertimeout);
451 get_sec(1, &secureobj, &secureindex);
454 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
455 rxperf_ExecuteRequest);
457 errx(1, "Cant create server");
459 rx_SetMinProcs(service, minprocs);
460 rx_SetMaxProcs(service, maxprocs);
462 rx_SetCheckReach(service, 1);
474 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
483 *readwrite = malloc(sizeof(afs_uint32) * len);
484 buf = malloc(RXPERF_BUFSIZE);
486 if (*readwrite == NULL)
489 f = fopen(filename, "r");
493 while (fgets(buf, sizeof(buf), f) != NULL) {
496 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
497 if (*readwrite == NULL)
502 data = htonl(strtol(buf, &ptr, 0));
503 if (ptr && ptr == buf)
504 errx(1, "can't resolve number of bytes to transfer");
509 (*readwrite)[num] = data;
522 struct rx_connection *conn;
532 client_thread( void *vparams)
534 struct client_data *params = (struct client_data *)vparams;
535 struct rx_call *call;
538 afs_uint32 *readwrite;
543 for (i = 0; i < params->times; i++) {
545 DBFPRINT(("starting command "));
547 call = rx_NewCall(params->conn);
549 errx(1, "rx_NewCall failed");
551 data = htonl(RX_PERF_VERSION);
552 if (rx_Write32(call, &data) != 4)
553 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
555 data = htonl(params->command);
556 if (rx_Write32(call, &data) != 4)
557 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
559 data = htonl(rxread_size);
560 if (rx_Write32(call, &data) != 4)
561 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
562 data = htonl(rxwrite_size);
563 if (rx_Write32(call, &data) != 4)
564 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
567 switch (params->command) {
569 DBFPRINT(("command "));
571 data = htonl(params->bytes);
572 if (rx_Write32(call, &data) != 4)
573 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
575 DBFPRINT(("sending(%d) ", params->bytes));
576 if (do_readbytes(call, params->bytes))
577 errx(1, "sendbytes (err %d)", rx_Error(call));
579 if (rx_Read32(call, &data) != 4)
580 errx(1, "failed to read result from server (err %d)", rx_Error(call));
582 if (data != htonl(RXPERF_MAGIC_COOKIE))
583 warn("server send wrong magic cookie in responce");
585 DBFPRINT(("done\n"));
589 DBFPRINT(("command "));
591 data = htonl(params->bytes);
592 if (rx_Write32(call, &data) != 4)
593 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
595 DBFPRINT(("sending(%d) ", params->bytes));
596 if (do_sendbytes(call, params->bytes))
597 errx(1, "sendbytes (err %d)", rx_Error(call));
599 if (rx_Read32(call, &data) != 4)
600 errx(1, "failed to read result from server (err %d)", rx_Error(call));
602 if (data != htonl(RXPERF_MAGIC_COOKIE))
603 warn("server send wrong magic cookie in responce");
605 DBFPRINT(("done\n"));
609 DBFPRINT(("commands "));
611 data = htonl(params->sendbytes);
612 if (rx_Write32(call, &data) != 4)
613 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
615 data = htonl(params->readbytes);
616 if (rx_Write32(call, &data) != 4)
617 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
619 DBFPRINT(("send(%d) ", params->sendbytes));
620 if (do_sendbytes(call, params->sendbytes))
621 errx(1, "sendbytes (err %d)", rx_Error(call));
623 DBFPRINT(("recv(%d) ", params->readbytes));
624 if (do_readbytes(call, params->readbytes))
625 errx(1, "sendbytes (err %d)", rx_Error(call));
627 if (rx_Read32(call, &data) != 4)
628 errx(1, "failed to read result from server (err %d)", rx_Error(call));
630 if (data != htonl(RXPERF_MAGIC_COOKIE))
631 warn("server send wrong magic cookie in responce");
633 DBFPRINT(("done\n"));
638 readfile(params->filename, &readwrite, &num);
641 if (rx_Write32(call, &data) != 4)
642 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
644 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
645 != num * sizeof(afs_uint32))
646 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
648 for (j = 0; j < num; j++) {
649 if (readwrite[j] == 0)
652 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
655 if (do_readbytes(call, size))
656 errx(1, "sendbytes (err %d)", rx_Error(call));
657 DBFPRINT(("read\n"));
659 if (do_sendbytes(call, size))
660 errx(1, "sendbytes (err %d)", rx_Error(call));
661 DBFPRINT(("send\n"));
672 #ifdef AFS_PTHREAD_ENV
674 AFS_UNREACHED(return NULL);
685 do_client(const char *server, short port, char *filename, afs_int32 command,
686 afs_int32 times, afs_int32 bytes, afs_int32 sendbytes, afs_int32 readbytes,
687 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
688 int udpbufsz, int nostats, int hotthread, int threads, FILE *output)
690 struct rx_connection *conn;
692 struct rx_securityClass *secureobj;
696 struct client_data *params;
698 #ifdef AFS_PTHREAD_ENV
700 pthread_t thread[MAX_THREADS];
701 pthread_attr_t tattr;
705 params = calloc(1, sizeof(struct client_data));
708 if (afs_winsockInit() < 0) {
709 printf("Can't initialize winsock.\n");
715 rx_EnableHotThread();
720 addr = str2addr(server);
722 rx_SetUdpBufSize(udpbufsz);
726 errx(1, "rx_Init failed");
732 rx_SetMaxMTU(maxmtu);
735 rx_SetMaxReceiveWindow(maxwsize);
736 rx_SetMaxSendWindow(maxwsize);
740 rx_SetMinPeerTimeout(minpeertimeout);
743 get_sec(0, &secureobj, &secureindex);
747 sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
748 threads, times, sendbytes, readbytes);
751 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
752 threads, times, bytes);
755 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
756 threads, times, bytes);
759 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
760 filename, threads, times, bytes);
764 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
766 errx(1, "failed to contact server");
768 #ifdef AFS_PTHREAD_ENV
769 pthread_attr_init(&tattr);
770 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
774 params->filename = filename;
775 params->command = command;
776 params->times = times;
777 params->bytes = bytes;
778 params->sendbytes = sendbytes;
779 params->readbytes = readbytes;
783 #ifdef AFS_PTHREAD_ENV
784 for ( i=0; i<threads; i++) {
785 pthread_create(&thread[i], &tattr, client_thread, params);
786 if ( (i + 1) % RX_MAXCALLS == 0 ) {
787 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
789 struct client_data *new_params = malloc(sizeof(struct client_data));
790 memcpy(new_params, params, sizeof(struct client_data));
791 new_params->conn = conn;
797 client_thread(params);
800 #ifdef AFS_PTHREAD_ENV
801 for ( i=0; i<threads; i++)
802 pthread_join(thread[i], &status);
807 end_and_print_timer(output, stamp, (long long)threads*times*(sendbytes+readbytes));
812 end_and_print_timer(output, stamp, (long long)threads*times*bytes);
816 DBFPRINT(("done for good\n"));
820 rx_PrintStats(output);
821 rx_PrintPeerStats(output, rx_PeerOf(conn));
825 #ifdef AFS_PTHREAD_ENV
826 pthread_attr_destroy(&tattr);
837 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", getprogname());
838 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", getprogname());
840 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
842 fprintf(stderr, "usage: %s client -c file -f filename\n", getprogname());
844 "%s: usage: common option to the client "
845 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
847 fprintf(stderr, "usage: %s server -p port\n", getprogname());
855 * do argument processing and call networking functions
859 rxperf_server(int argc, char **argv)
861 short port = DEFAULT_PORT;
865 int udpbufsz = 64 * 1024;
870 int minpeertimeout = 0;
874 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:S:V")) != -1) {
878 rx_debugFile = fopen(optarg, "w");
879 if (rx_debugFile == NULL)
880 err(1, "fopen %s", optarg);
882 errx(1, "compiled without RXDEBUG");
886 rxread_size = strtol(optarg, &ptr, 0);
887 if (ptr != 0 && ptr[0] != '\0')
888 errx(1, "can't resolve readsize");
889 if (rxread_size > sizeof(somebuf))
890 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxread_size,
894 minprocs = strtol(optarg, &ptr, 0);
895 if (ptr != 0 && ptr[0] != '\0')
896 errx(1, "can't resolve minprocs");
899 maxprocs = strtol(optarg, &ptr, 0);
900 if (ptr != 0 && ptr[0] != '\0')
901 errx(1, "can't resolve maxprocs");
904 minpeertimeout = strtol(optarg, &ptr, 0);
905 if (ptr != 0 && ptr[0] != '\0')
906 errx(1, "can't resolve min peer timeout");
909 port = (short) strtol(optarg, &ptr, 0);
910 if (ptr != 0 && ptr[0] != '\0')
911 errx(1, "can't resolve portname");
914 rxwrite_size = strtol(optarg, &ptr, 0);
915 if (ptr != 0 && ptr[0] != '\0')
916 errx(1, "can't resolve writesize");
917 if (rxwrite_size > sizeof(somebuf))
918 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxwrite_size,
931 maxmtu = strtol(optarg, &ptr, 0);
932 if (ptr && *ptr != '\0')
933 errx(1, "can't resolve rx maxmtu to use");
936 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
937 if (ptr && *ptr != '\0')
938 errx(1, "can't resolve upd buffer size (Kbytes)");
944 maxwsize = strtol(optarg, &ptr, 0);
945 if (ptr && *ptr != '\0')
946 errx(1, "can't resolve max send/recv window size (packets)");
959 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
960 nostats, hotthreads, minprocs, maxprocs);
966 * do argument processing and call networking functions
970 rxperf_client(int argc, char **argv)
972 char *host = DEFAULT_HOST;
973 int bytes = DEFAULT_BYTES;
974 short port = DEFAULT_PORT;
975 char *filename = NULL;
986 int udpbufsz = 64 * 1024;
988 int minpeertimeout = 0;
993 cmd = RX_PERF_UNKNOWN;
995 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:o:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
998 bytes = strtol(optarg, &ptr, 0);
999 if (ptr && *ptr != '\0')
1000 errx(1, "can't resolve number of bytes to transfer");
1003 if (strcasecmp(optarg, "send") == 0)
1005 else if (strcasecmp(optarg, "recv") == 0)
1007 else if (strcasecmp(optarg, "rpc") == 0)
1009 else if (strcasecmp(optarg, "file") == 0)
1012 errx(1, "unknown command %s", optarg);
1016 rx_debugFile = fopen(optarg, "w");
1017 if (rx_debugFile == NULL)
1018 err(1, "fopen %s", optarg);
1020 errx(1, "compiled without RXDEBUG");
1024 if (output == NULL) {
1025 output = fopen(optarg, "w");
1026 if (output == NULL) {
1027 err(1, "can't open %s", optarg);
1030 warnx("-o option given more than once, ignoring -o %s", optarg);
1034 minpeertimeout = strtol(optarg, &ptr, 0);
1035 if (ptr != 0 && ptr[0] != '\0')
1036 errx(1, "can't resolve min peer timeout");
1039 port = (short) strtol(optarg, &ptr, 0);
1040 if (ptr != 0 && ptr[0] != '\0')
1041 errx(1, "can't resolve portname");
1044 rxread_size = strtol(optarg, &ptr, 0);
1045 if (ptr != 0 && ptr[0] != '\0')
1046 errx(1, "can't resolve readsize");
1047 if (rxread_size > sizeof(somebuf))
1048 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxread_size,
1052 host = strdup(optarg);
1060 rxwrite_size = strtol(optarg, &ptr, 0);
1061 if (ptr != 0 && ptr[0] != '\0')
1062 errx(1, "can't resolve writesize");
1063 if (rxwrite_size > sizeof(somebuf))
1064 errx(1, "%d > sizeof(somebuf) (%"AFS_SIZET_FMT")", rxwrite_size,
1068 maxwsize = strtol(optarg, &ptr, 0);
1069 if (ptr && *ptr != '\0')
1070 errx(1, "can't resolve max send/recv window size (packets)");
1073 times = strtol(optarg, &ptr, 0);
1074 if (ptr && *ptr != '\0')
1075 errx(1, "can't resolve number of times to execute rpc");
1078 sendbytes = strtol(optarg, &ptr, 0);
1079 if (ptr && *ptr != '\0')
1080 errx(1, "can't resolve number of bytes to send");
1083 readbytes = strtol(optarg, &ptr, 0);
1084 if (ptr && *ptr != '\0')
1085 errx(1, "can't resolve number of bytes to receive");
1088 #ifdef AFS_PTHREAD_ENV
1089 threads = strtol(optarg, &ptr, 0);
1090 if (ptr && *ptr != '\0')
1091 errx(1, "can't resolve number of threads to execute");
1092 if (threads > MAX_THREADS)
1093 errx(1, "too many threads");
1095 errx(1, "Not built for pthreads");
1114 maxmtu = strtol(optarg, &ptr, 0);
1115 if (ptr && *ptr != '\0')
1116 errx(1, "can't resolve rx maxmtu to use");
1119 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1120 if (ptr && *ptr != '\0')
1121 errx(1, "can't resolve upd buffer size (Kbytes)");
1131 if (nostats && dumpstats)
1132 errx(1, "cannot set both -N and -D");
1134 if (threads > 1 && cmd == RX_PERF_FILE)
1135 errx(1, "cannot use multiple threads with file command");
1140 if (cmd == RX_PERF_UNKNOWN)
1141 errx(1, "no command given to the client");
1143 do_client(host, port, filename, cmd, times, bytes, sendbytes,
1144 readbytes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1145 udpbufsz, nostats, hotthreads, threads,
1146 (output == NULL ? stdout : output));
1148 if (output != NULL) {
1149 if (fclose(output) < 0) {
1158 * setup world and call cmd
1162 main(int argc, char **argv)
1164 #ifndef AFS_PTHREAD_ENV
1168 setprogname(argv[0]);
1170 #ifndef AFS_NT40_ENV
1171 signal(SIGUSR1, sigusr1);
1172 signal(SIGINT, sigint);
1175 #ifndef AFS_PTHREAD_ENV
1176 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1179 memset(somebuf, 0, sizeof(somebuf));
1181 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1182 rxperf_server(argc - 1, argv + 1);
1183 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1184 rxperf_client(argc - 1, argv + 1);