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 #include <sys/types.h>
55 #include <sys/socket.h>
58 #include <netinet/in.h>
59 #include <arpa/inet.h>
78 #include <err.h> /* not stricly right, but if we have a errx() there
79 * is hopefully a err.h */
84 #include "rx_globals.h"
86 #ifdef AFS_PTHREAD_ENV
88 #define MAX_THREADS 128
91 static const char *__progname;
95 warnx(const char *fmt, ...)
100 fprintf(stderr, "%s: ", __progname);
101 vfprintf(stderr, fmt, args);
102 fprintf(stderr, "\n");
105 #endif /* !HAVE_WARNX */
109 errx(int eval, const char *fmt, ...)
114 fprintf(stderr, "%s: ", __progname);
115 vfprintf(stderr, fmt, args);
116 fprintf(stderr, "\n");
121 #endif /* !HAVE_ERRX */
125 warn(const char *fmt, ...)
131 fprintf(stderr, "%s: ", __progname);
132 vfprintf(stderr, fmt, args);
134 errstr = strerror(errno);
136 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
139 #endif /* !HAVE_WARN */
143 err(int eval, const char *fmt, ...)
149 fprintf(stderr, "%s: ", __progname);
150 vfprintf(stderr, fmt, args);
152 errstr = strerror(errno);
154 fprintf(stderr, ": %s\n", errstr ? errstr : "unknown error");
159 #endif /* !HAVE_ERR */
161 #define DEFAULT_PORT 7009 /* To match tcpdump */
162 #define DEFAULT_HOST "127.0.0.1"
163 #define DEFAULT_BYTES 1024 * 1024
164 #define RXPERF_BUFSIZE 512 * 1024
166 enum { RX_PERF_VERSION = 3 };
167 enum { RX_SERVER_ID = 147 };
168 enum { RX_PERF_UNKNOWN = -1,
175 enum { RXPERF_MAGIC_COOKIE = 0x4711 };
182 #define DBFPRINT(x) do { printf x ; } while(0)
190 exit(2); /* XXX profiler */
197 exit(2); /* XXX profiler */
204 static struct timeval timer_start;
205 static struct timeval timer_stop;
206 static int timer_check = 0;
212 gettimeofday(&timer_start, NULL);
220 end_and_print_timer(char *str)
222 long long start_l, stop_l;
225 assert(timer_check == 0);
226 gettimeofday(&timer_stop, NULL);
227 start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
228 stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
229 printf("%s:\t%8llu msec\n", str, (stop_l - start_l) / 1000);
237 str2addr(const char *s)
239 struct in_addr server;
243 #define INADDR_NONE 0xffffffff
245 if (inet_addr(s) != INADDR_NONE)
247 h = gethostbyname(s);
249 memcpy(&server, h->h_addr_list[0], sizeof(server));
250 return server.s_addr;
261 get_sec(int serverp, struct rx_securityClass **sec, int *secureindex)
264 *sec = rxnull_NewServerSecurityObject();
267 *sec = rxnull_NewClientSecurityObject();
273 * process the "RPC" and return the results
276 char somebuf[RXPERF_BUFSIZE];
278 afs_int32 rxwrite_size = sizeof(somebuf);
279 afs_int32 rxread_size = sizeof(somebuf);
280 afs_int32 use_rx_readv = 0;
283 do_readbytes(struct rx_call *call, afs_int32 bytes)
285 struct iovec tiov[RX_MAXIOVECS];
296 if (size > RX_MAX_PACKET_DATA_SIZE)
297 size = RX_MAX_PACKET_DATA_SIZE;
298 code = rx_Readv(call, tiov, &tnio, RX_MAXIOVECS, size);
300 code = rx_Read(call, somebuf, size);
310 do_sendbytes(struct rx_call *call, afs_int32 bytes)
318 if (rx_Write(call, somebuf, size) != size)
327 rxperf_ExecuteRequest(struct rx_call *call)
336 afs_uint32 *readwrite;
340 DBFPRINT(("got a request\n"));
342 if (rx_Read32(call, &version) != 4) {
343 warn("rx_Read failed to read version");
347 if (htonl(RX_PERF_VERSION) != version) {
348 warnx("client has wrong version");
352 if (rx_Read32(call, &command) != 4) {
353 warnx("rx_Read failed to read command");
356 command = ntohl(command);
358 if (rx_Read32(call, &data) != 4) {
359 warnx("rx_Read failed to read size");
362 rxread_size = ntohl(data);
363 if (rxread_size > sizeof(somebuf)) {
364 warnx("rxread_size too large %d", rxread_size);
368 if (rx_Read32(call, &data) != 4) {
369 warnx("rx_Read failed to write size");
372 rxwrite_size = ntohl(data);
373 if (rxwrite_size > sizeof(somebuf)) {
374 warnx("rxwrite_size too large %d", rxwrite_size);
380 DBFPRINT(("got a send request\n"));
382 if (rx_Read32(call, &bytes) != 4) {
383 warnx("rx_Read failed to read bytes");
386 bytes = ntohl(bytes);
388 DBFPRINT(("reading(%d) ", bytes));
389 do_readbytes(call, bytes);
391 data = htonl(RXPERF_MAGIC_COOKIE);
392 if (rx_Write32(call, &data) != 4) {
393 warnx("rx_Write failed when sending back result");
396 DBFPRINT(("done\n"));
400 DBFPRINT(("got a rpc request, reading commands\n"));
402 if (rx_Read32(call, &recvb) != 4) {
403 warnx("rx_Read failed to read recvbytes");
406 recvb = ntohl(recvb);
407 if (rx_Read32(call, &sendb) != 4) {
408 warnx("rx_Read failed to read sendbytes");
411 sendb = ntohl(sendb);
413 DBFPRINT(("read(%d) ", recvb));
414 if (do_readbytes(call, recvb)) {
415 warnx("do_readbytes failed");
418 DBFPRINT(("send(%d) ", sendb));
419 if (do_sendbytes(call, sendb)) {
420 warnx("sendbytes failed");
424 DBFPRINT(("done\n"));
426 data = htonl(RXPERF_MAGIC_COOKIE);
427 if (rx_Write32(call, &data) != 4) {
428 warnx("rx_Write failed when sending back magic cookie");
434 if (rx_Read32(call, &data) != 4)
435 errx(1, "failed to read num from client");
438 readwrite = malloc(num * sizeof(afs_uint32));
439 if (readwrite == NULL)
442 if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) !=
443 num * sizeof(afs_uint32))
444 errx(1, "failed to read recvlist from client");
446 for (i = 0; i < num; i++) {
447 if (readwrite[i] == 0) {
448 DBFPRINT(("readp %d", readwrite[i]));
452 bytes = ntohl(readwrite[i]) * sizeof(afs_uint32);
455 DBFPRINT(("read\n"));
456 do_readbytes(call, bytes);
458 do_sendbytes(call, bytes);
459 DBFPRINT(("send\n"));
465 DBFPRINT(("got a recv request\n"));
467 if (rx_Read32(call, &bytes) != 4) {
468 warnx("rx_Read failed to read bytes");
471 bytes = ntohl(bytes);
473 DBFPRINT(("sending(%d) ", bytes));
474 do_sendbytes(call, bytes);
476 data = htonl(RXPERF_MAGIC_COOKIE);
477 if (rx_Write32(call, &data) != 4) {
478 warnx("rx_Write failed when sending back result");
481 DBFPRINT(("done\n"));
485 warnx("client sent a unsupported command");
488 DBFPRINT(("done with command\n"));
498 do_server(short port, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
499 int udpbufsz, int nostats, int hotthread,
500 int minprocs, int maxprocs)
502 struct rx_service *service;
503 struct rx_securityClass *secureobj;
508 if (afs_winsockInit() < 0) {
509 printf("Can't initialize winsock.\n");
515 rx_EnableHotThread();
520 rx_SetUdpBufSize(udpbufsz);
522 ret = rx_Init(htons(port));
524 errx(1, "rx_Init failed");
530 rx_SetMaxMTU(maxmtu);
533 rx_SetMaxReceiveWindow(maxwsize);
534 rx_SetMaxSendWindow(maxwsize);
538 rx_SetMinPeerTimeout(minpeertimeout);
541 get_sec(1, &secureobj, &secureindex);
544 rx_NewService(0, RX_SERVER_ID, "rxperf", &secureobj, secureindex,
545 rxperf_ExecuteRequest);
547 errx(1, "Cant create server");
549 rx_SetMinProcs(service, minprocs);
550 rx_SetMaxProcs(service, maxprocs);
552 rx_SetCheckReach(service, 1);
564 readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size)
573 *readwrite = malloc(sizeof(afs_uint32) * len);
574 buf = malloc(RXPERF_BUFSIZE);
576 if (*readwrite == NULL)
579 f = fopen(filename, "r");
583 while (fgets(buf, sizeof(buf), f) != NULL) {
586 *readwrite = realloc(*readwrite, len * sizeof(afs_uint32));
587 if (*readwrite == NULL)
592 data = htonl(strtol(buf, &ptr, 0));
593 if (ptr && ptr == buf)
594 errx(1, "can't resolve number of bytes to transfer");
599 (*readwrite)[num] = data;
612 struct rx_connection *conn;
622 client_thread( void *vparams)
624 struct client_data *params = (struct client_data *)vparams;
625 struct rx_call *call;
628 afs_uint32 *readwrite;
633 for (i = 0; i < params->times; i++) {
635 DBFPRINT(("starting command "));
637 call = rx_NewCall(params->conn);
639 errx(1, "rx_NewCall failed");
641 data = htonl(RX_PERF_VERSION);
642 if (rx_Write32(call, &data) != 4)
643 errx(1, "rx_Write failed to send version (err %d)", rx_Error(call));
645 data = htonl(params->command);
646 if (rx_Write32(call, &data) != 4)
647 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
649 data = htonl(rxread_size);
650 if (rx_Write32(call, &data) != 4)
651 errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call));
652 data = htonl(rxwrite_size);
653 if (rx_Write32(call, &data) != 4)
654 errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call));
657 switch (params->command) {
659 DBFPRINT(("command "));
661 data = htonl(params->bytes);
662 if (rx_Write32(call, &data) != 4)
663 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
665 DBFPRINT(("sending(%d) ", params->bytes));
666 if (do_readbytes(call, params->bytes))
667 errx(1, "sendbytes (err %d)", rx_Error(call));
669 if (rx_Read32(call, &data) != 4)
670 errx(1, "failed to read result from server (err %d)", rx_Error(call));
672 if (data != htonl(RXPERF_MAGIC_COOKIE))
673 warn("server send wrong magic cookie in responce");
675 DBFPRINT(("done\n"));
679 DBFPRINT(("command "));
681 data = htonl(params->bytes);
682 if (rx_Write32(call, &data) != 4)
683 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
685 DBFPRINT(("sending(%d) ", params->bytes));
686 if (do_sendbytes(call, params->bytes))
687 errx(1, "sendbytes (err %d)", rx_Error(call));
689 if (rx_Read32(call, &data) != 4)
690 errx(1, "failed to read result from server (err %d)", rx_Error(call));
692 if (data != htonl(RXPERF_MAGIC_COOKIE))
693 warn("server send wrong magic cookie in responce");
695 DBFPRINT(("done\n"));
699 DBFPRINT(("commands "));
701 data = htonl(params->sendbytes);
702 if (rx_Write32(call, &data) != 4)
703 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
705 data = htonl(params->readbytes);
706 if (rx_Write32(call, &data) != 4)
707 errx(1, "rx_Write failed to send command (err %d)", rx_Error(call));
709 DBFPRINT(("send(%d) ", params->sendbytes));
710 if (do_sendbytes(call, params->sendbytes))
711 errx(1, "sendbytes (err %d)", rx_Error(call));
713 DBFPRINT(("recv(%d) ", params->readbytes));
714 if (do_readbytes(call, params->readbytes))
715 errx(1, "sendbytes (err %d)", rx_Error(call));
717 if (rx_Read32(call, &data) != 4)
718 errx(1, "failed to read result from server (err %d)", rx_Error(call));
720 if (data != htonl(RXPERF_MAGIC_COOKIE))
721 warn("server send wrong magic cookie in responce");
723 DBFPRINT(("done\n"));
728 readfile(params->filename, &readwrite, &num);
731 if (rx_Write32(call, &data) != 4)
732 errx(1, "rx_Write failed to send size (err %d)", rx_Error(call));
734 if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32))
735 != num * sizeof(afs_uint32))
736 errx(1, "rx_Write failed to send list (err %d)", rx_Error(call));
738 for (j = 0; j < num; j++) {
739 if (readwrite[j] == 0)
742 size = ntohl(readwrite[j]) * sizeof(afs_uint32);
745 if (do_readbytes(call, size))
746 errx(1, "sendbytes (err %d)", rx_Error(call));
747 DBFPRINT(("read\n"));
749 if (do_sendbytes(call, size))
750 errx(1, "sendbytes (err %d)", rx_Error(call));
751 DBFPRINT(("send\n"));
762 #ifdef AFS_PTHREAD_ENV
774 do_client(const char *server, short port, char *filename, afs_int32 command,
775 afs_int32 times, afs_int32 bytes, afs_int32 sendbytes, afs_int32 readbytes,
776 int dumpstats, int nojumbo, int maxmtu, int maxwsize, int minpeertimeout,
777 int udpbufsz, int nostats, int hotthread, int threads)
779 struct rx_connection *conn;
781 struct rx_securityClass *secureobj;
785 struct client_data *params;
787 #ifdef AFS_PTHREAD_ENV
789 pthread_t thread[MAX_THREADS];
790 pthread_attr_t tattr;
794 params = malloc(sizeof(struct client_data));
795 memset(params, 0, sizeof(struct client_data));
798 if (afs_winsockInit() < 0) {
799 printf("Can't initialize winsock.\n");
805 rx_EnableHotThread();
810 addr = str2addr(server);
812 rx_SetUdpBufSize(udpbufsz);
816 errx(1, "rx_Init failed");
822 rx_SetMaxMTU(maxmtu);
825 rx_SetMaxReceiveWindow(maxwsize);
826 rx_SetMaxSendWindow(maxwsize);
830 rx_SetMinPeerTimeout(minpeertimeout);
833 get_sec(0, &secureobj, &secureindex);
835 conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
837 errx(1, "failed to contact server");
839 #ifdef AFS_PTHREAD_ENV
840 pthread_attr_init(&tattr);
841 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
845 params->filename = filename;
846 params->command = command;
847 params->times = times;
848 params->bytes = bytes;
849 params->sendbytes = sendbytes;
850 params->readbytes = readbytes;
854 sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
855 threads, times, sendbytes, readbytes);
858 sprintf(stamp, "RECV: threads\t%d, times\t%d, bytes\t%d",
859 threads, times, bytes);
862 sprintf(stamp, "SEND: threads\t%d, times\t%d, bytes\t%d",
863 threads, times, bytes);
866 sprintf(stamp, "FILE %s: threads\t%d, times\t%d, bytes\t%d",
867 filename, threads, times, bytes);
873 #ifdef AFS_PTHREAD_ENV
874 for ( i=0; i<threads; i++)
875 pthread_create(&thread[i], &tattr, client_thread, params);
877 client_thread(params);
880 #ifdef AFS_PTHREAD_ENV
881 for ( i=0; i<threads; i++)
882 pthread_join(thread[i], &status);
885 end_and_print_timer(stamp);
886 DBFPRINT(("done for good\n"));
889 rx_PrintStats(stdout);
890 rx_PrintPeerStats(stdout, conn->peer);
894 #ifdef AFS_PTHREAD_ENV
895 pthread_attr_destroy(&tattr);
906 fprintf(stderr, "usage: %s client -c send -b <bytes>\n", __progname);
907 fprintf(stderr, "usage: %s client -c recv -b <bytes>\n", __progname);
909 "usage: %s client -c rpc -S <sendbytes> -R <recvbytes>\n",
911 fprintf(stderr, "usage: %s client -c file -f filename\n", __progname);
913 "%s: usage: common option to the client "
914 "-w <write-bytes> -r <read-bytes> -T times -p port -s server -D\n",
916 fprintf(stderr, "usage: %s server -p port\n", __progname);
924 * do argument processing and call networking functions
928 rxperf_server(int argc, char **argv)
930 short port = DEFAULT_PORT;
934 int udpbufsz = 64 * 1024;
939 int minpeertimeout = 0;
943 while ((ch = getopt(argc, argv, "r:d:p:P:w:W:HNjm:u:4:s:SV")) != -1) {
947 rx_debugFile = fopen(optarg, "w");
948 if (rx_debugFile == NULL)
949 err(1, "fopen %s", optarg);
951 errx(1, "compiled without RXDEBUG");
955 rxread_size = strtol(optarg, &ptr, 0);
956 if (ptr != 0 && ptr[0] != '\0')
957 errx(1, "can't resolve readsize");
958 if (rxread_size > sizeof(somebuf))
959 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
963 minprocs = strtol(optarg, &ptr, 0);
964 if (ptr != 0 && ptr[0] != '\0')
965 errx(1, "can't resolve minprocs");
968 maxprocs = strtol(optarg, &ptr, 0);
969 if (ptr != 0 && ptr[0] != '\0')
970 errx(1, "can't resolve maxprocs");
973 minpeertimeout = strtol(optarg, &ptr, 0);
974 if (ptr != 0 && ptr[0] != '\0')
975 errx(1, "can't resolve min peer timeout");
978 port = (short) strtol(optarg, &ptr, 0);
979 if (ptr != 0 && ptr[0] != '\0')
980 errx(1, "can't resolve portname");
983 rxwrite_size = strtol(optarg, &ptr, 0);
984 if (ptr != 0 && ptr[0] != '\0')
985 errx(1, "can't resolve writesize");
986 if (rxwrite_size > sizeof(somebuf))
987 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1000 maxmtu = strtol(optarg, &ptr, 0);
1001 if (ptr && *ptr != '\0')
1002 errx(1, "can't resolve rx maxmtu to use");
1005 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1006 if (ptr && *ptr != '\0')
1007 errx(1, "can't resolve upd buffer size (Kbytes)");
1013 maxwsize = strtol(optarg, &ptr, 0);
1014 if (ptr && *ptr != '\0')
1015 errx(1, "can't resolve max send/recv window size (packets)");
1028 do_server(port, nojumbo, maxmtu, maxwsize, minpeertimeout, udpbufsz,
1029 nostats, hotthreads, minprocs, maxprocs);
1035 * do argument processing and call networking functions
1039 rxperf_client(int argc, char **argv)
1041 char *host = DEFAULT_HOST;
1042 int bytes = DEFAULT_BYTES;
1043 short port = DEFAULT_PORT;
1044 char *filename = NULL;
1055 int udpbufsz = 64 * 1024;
1057 int minpeertimeout = 0;
1061 cmd = RX_PERF_UNKNOWN;
1063 while ((ch = getopt(argc, argv, "T:S:R:b:c:d:p:P:r:s:w:W:f:HDNjm:u:4:t:V")) != -1) {
1066 bytes = strtol(optarg, &ptr, 0);
1067 if (ptr && *ptr != '\0')
1068 errx(1, "can't resolve number of bytes to transfer");
1071 if (strcasecmp(optarg, "send") == 0)
1073 else if (strcasecmp(optarg, "recv") == 0)
1075 else if (strcasecmp(optarg, "rpc") == 0)
1077 else if (strcasecmp(optarg, "file") == 0)
1080 errx(1, "unknown command %s", optarg);
1084 rx_debugFile = fopen(optarg, "w");
1085 if (rx_debugFile == NULL)
1086 err(1, "fopen %s", optarg);
1088 errx(1, "compiled without RXDEBUG");
1092 minpeertimeout = strtol(optarg, &ptr, 0);
1093 if (ptr != 0 && ptr[0] != '\0')
1094 errx(1, "can't resolve min peer timeout");
1097 port = (short) strtol(optarg, &ptr, 0);
1098 if (ptr != 0 && ptr[0] != '\0')
1099 errx(1, "can't resolve portname");
1102 rxread_size = strtol(optarg, &ptr, 0);
1103 if (ptr != 0 && ptr[0] != '\0')
1104 errx(1, "can't resolve readsize");
1105 if (rxread_size > sizeof(somebuf))
1106 errx(1, "%d > sizeof(somebuf) (%d)", rxread_size,
1110 host = strdup(optarg);
1118 rxwrite_size = strtol(optarg, &ptr, 0);
1119 if (ptr != 0 && ptr[0] != '\0')
1120 errx(1, "can't resolve writesize");
1121 if (rxwrite_size > sizeof(somebuf))
1122 errx(1, "%d > sizeof(somebuf) (%d)", rxwrite_size,
1126 maxwsize = strtol(optarg, &ptr, 0);
1127 if (ptr && *ptr != '\0')
1128 errx(1, "can't resolve max send/recv window size (packets)");
1131 times = strtol(optarg, &ptr, 0);
1132 if (ptr && *ptr != '\0')
1133 errx(1, "can't resolve number of times to execute rpc");
1136 sendbytes = strtol(optarg, &ptr, 0);
1137 if (ptr && *ptr != '\0')
1138 errx(1, "can't resolve number of bytes to send");
1141 readbytes = strtol(optarg, &ptr, 0);
1142 if (ptr && *ptr != '\0')
1143 errx(1, "can't resolve number of bytes to receive");
1146 #ifdef AFS_PTHREAD_ENV
1147 threads = strtol(optarg, &ptr, 0);
1148 if (ptr && *ptr != '\0')
1149 errx(1, "can't resolve number of threads to execute");
1150 if (threads > MAX_THREADS)
1151 errx(1, "too many threads");
1153 errx(1, "Not built for pthreads");
1172 maxmtu = strtol(optarg, &ptr, 0);
1173 if (ptr && *ptr != '\0')
1174 errx(1, "can't resolve rx maxmtu to use");
1177 udpbufsz = strtol(optarg, &ptr, 0) * 1024;
1178 if (ptr && *ptr != '\0')
1179 errx(1, "can't resolve upd buffer size (Kbytes)");
1189 if (nostats && dumpstats)
1190 errx(1, "cannot set both -N and -D");
1192 if (threads > 1 && cmd == RX_PERF_FILE)
1193 errx(1, "cannot use multiple threads with file command");
1198 if (cmd == RX_PERF_UNKNOWN)
1199 errx(1, "no command given to the client");
1201 do_client(host, port, filename, cmd, times, bytes, sendbytes,
1202 readbytes, dumpstats, nojumbo, maxmtu, maxwsize, minpeertimeout,
1203 udpbufsz, nostats, hotthreads, threads);
1209 * setup world and call cmd
1213 main(int argc, char **argv)
1215 #ifndef AFS_PTHREAD_ENV
1219 __progname = strrchr(argv[0], '/');
1220 if (__progname == 0)
1221 __progname = argv[0];
1223 #ifndef AFS_NT40_ENV
1224 signal(SIGUSR1, sigusr1);
1225 signal(SIGINT, sigint);
1228 #ifndef AFS_PTHREAD_ENV
1229 LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
1232 memset(somebuf, 0, sizeof(somebuf));
1234 if (argc >= 2 && strcmp(argv[1], "server") == 0)
1235 rxperf_server(argc - 1, argv + 1);
1236 else if (argc >= 2 && strcmp(argv[1], "client") == 0)
1237 rxperf_client(argc - 1, argv + 1);