From: Simon Wilkinson Date: Sun, 26 Sep 2010 14:20:22 +0000 (+0100) Subject: Fix rxperf so that it works with pthreads X-Git-Tag: openafs-devel-1_5_78~113 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=5b4e1b9618502092ada077905398d0ed1435602f;p=packages%2Fo%2Fopenafs.git Fix rxperf so that it works with pthreads *) Don't allocate 512K on the stack *) Don't pass stack allocated data into pthread_create() Reviewed-on: http://gerrit.openafs.org/2854 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman (cherry picked from commit 8c0498699366f7e40253d00604da3d9043b32851) Change-Id: Iadf2c5512e50aa3f10ee583dddfe5d580e0542bf Reviewed-on: http://gerrit.openafs.org/2925 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/rx/test/rxperf.c b/src/rx/test/rxperf.c index 2985f732f..cef5d894f 100644 --- a/src/rx/test/rxperf.c +++ b/src/rx/test/rxperf.c @@ -555,9 +555,10 @@ readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size) afs_uint32 num = 0; afs_uint32 data; char *ptr; - char buf[RXPERF_BUFSIZE]; + char *buf; *readwrite = malloc(sizeof(afs_uint32) * len); + buf = malloc(RXPERF_BUFSIZE); if (*readwrite == NULL) err(1, "malloc"); @@ -591,6 +592,7 @@ readfile(const char *filename, afs_uint32 ** readwrite, afs_uint32 * size) if (fclose(f) == -1) err(1, "fclose"); + free(buf); } struct client_data { @@ -767,7 +769,7 @@ do_client(const char *server, short port, char *filename, afs_int32 command, int secureindex; int ret; char stamp[2048]; - struct client_data params; + struct client_data *params; #ifdef AFS_PTHREAD_ENV int i; @@ -776,6 +778,9 @@ do_client(const char *server, short port, char *filename, afs_int32 command, void *status; #endif + params = malloc(sizeof(struct client_data)); + memset(params, 0, sizeof(struct client_data)); + #ifdef AFS_NT40_ENV if (afs_winsockInit() < 0) { printf("Can't initialize winsock.\n"); @@ -822,13 +827,13 @@ do_client(const char *server, short port, char *filename, afs_int32 command, pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); #endif - params.conn = conn; - params.filename = filename; - params.command = command; - params.times = times; - params.bytes = bytes; - params.sendtimes = sendtimes; - params.recvtimes = recvtimes; + params->conn = conn; + params->filename = filename; + params->command = command; + params->times = times; + params->bytes = bytes; + params->sendtimes = sendtimes; + params->recvtimes = recvtimes; switch (command) { case RX_PERF_RPC: @@ -853,9 +858,9 @@ do_client(const char *server, short port, char *filename, afs_int32 command, #ifdef AFS_PTHREAD_ENV for ( i=0; i