rxperf: use parallel connections
[openafs.git] / src / rx / test / rxperf.c
index 342f20b..3f4a918 100644 (file)
@@ -79,9 +79,9 @@ nn * We are using getopt since we want it to be possible to link to
                                 * is hopefully a err.h */
 #endif
 #include <getopt.h>
-#include "rx.h"
-#include "rx_null.h"
-#include "rx_globals.h"
+#include <rx/rx.h>
+#include <rx/rx_null.h>
+#include <rx/rx_globals.h>
 
 #ifdef AFS_PTHREAD_ENV
 #include <pthread.h>
@@ -832,23 +832,6 @@ do_client(const char *server, short port, char *filename, afs_int32 command,
 
     get_sec(0, &secureobj, &secureindex);
 
-    conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
-    if (conn == NULL)
-       errx(1, "failed to contact server");
-
-#ifdef AFS_PTHREAD_ENV
-    pthread_attr_init(&tattr);
-    pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
-#endif
-
-    params->conn = conn;
-    params->filename = filename;
-    params->command = command;
-    params->times = times;
-    params->bytes = bytes;
-    params->sendbytes = sendbytes;
-    params->readbytes = readbytes;
-
     switch (command) {
     case RX_PERF_RPC:
         sprintf(stamp, "RPC: threads\t%d, times\t%d, write bytes\t%d, read bytes\t%d",
@@ -868,11 +851,38 @@ do_client(const char *server, short port, char *filename, afs_int32 command,
         break;
     }
 
+    conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
+    if (conn == NULL)
+       errx(1, "failed to contact server");
+
+#ifdef AFS_PTHREAD_ENV
+    pthread_attr_init(&tattr);
+    pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE);
+#endif
+
+    params->conn = conn;
+    params->filename = filename;
+    params->command = command;
+    params->times = times;
+    params->bytes = bytes;
+    params->sendbytes = sendbytes;
+    params->readbytes = readbytes;
+
     start_timer();
 
 #ifdef AFS_PTHREAD_ENV
-    for ( i=0; i<threads; i++)
+    for ( i=0; i<threads; i++) {
         pthread_create(&thread[i], &tattr, client_thread, params);
+        if ( (i + 1) % RX_MAXCALLS == 0 ) {
+            conn = rx_NewConnection(addr, htons(port), RX_SERVER_ID, secureobj, secureindex);
+            if (conn != NULL) {
+                struct client_data *new_params = malloc(sizeof(struct client_data));
+                memcpy(new_params, params, sizeof(struct client_data));
+                new_params->conn = conn;
+                params = new_params;
+            }
+        }
+    }
 #else
         client_thread(params);
 #endif