From 636f761cf2248c924efcb272271fa8e294190e1d Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 17 Jul 2012 17:03:46 -0700 Subject: [PATCH] Refresh of rstream-fork --- examples/rstream.c | 26 ++++++++++++++++++++++---- man/rstream.1 | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/examples/rstream.c b/examples/rstream.c index 48e2771e..70bd2526 100644 --- a/examples/rstream.c +++ b/examples/rstream.c @@ -84,6 +84,8 @@ static int verify; static int flags = MSG_DONTWAIT; static int poll_timeout = 0; static int custom; +static int use_fork; +static pid_t fork_pid; static enum rs_optimization optimization; static int size_option; static int iterations = 1; @@ -463,7 +465,11 @@ static int server_connect(void) perror("raccept"); } - set_options(rs); + if (use_fork) + fork_pid = fork(); + + if (!fork_pid) + set_options(rs); return ret; } @@ -546,7 +552,7 @@ static int run(void) if (ret) goto free; - for (i = 0; i < TEST_CNT; i++) { + for (i = 0; i < TEST_CNT && !fork_pid; i++) { if (test_size[i].option > size_option) continue; init_latency_test(test_size[i].size); @@ -555,11 +561,14 @@ static int run(void) rs_shutdown(rs, SHUT_RDWR); rs_close(rs); + if (use_fork && !fork_pid) + goto free; + optimization = opt_bandwidth; ret = dst_addr ? client_connect() : server_connect(); if (ret) goto free; - for (i = 0; i < TEST_CNT; i++) { + for (i = 0; i < TEST_CNT && !fork_pid; i++) { if (test_size[i].option > size_option) continue; init_bandwidth_test(test_size[i].size); @@ -570,7 +579,8 @@ static int run(void) if (ret) goto free; - ret = run_test(); + if (!fork_pid) + ret = run_test(); } rs_shutdown(rs, SHUT_RDWR); @@ -593,6 +603,10 @@ static int set_test_opt(char *optarg) case 'b': flags &= ~MSG_DONTWAIT; break; + case 'f': + use_fork = 1; + use_rs = 0; + break; case 'n': flags |= MSG_DONTWAIT; break; @@ -613,6 +627,9 @@ static int set_test_opt(char *optarg) flags |= MSG_DONTWAIT; } else if (!strncasecmp("verify", optarg, 6)) { verify = 1; + } else if (!strncasecmp("fork", optarg, 4)) { + use_fork = 1; + use_rs = 0; } else { return -1; } @@ -671,6 +688,7 @@ int main(int argc, char **argv) printf("\t s|sockets - use standard tcp/ip sockets\n"); printf("\t a|async - asynchronous operation (use poll)\n"); printf("\t b|blocking - use blocking calls\n"); + printf("\t f|fork - fork server processing\n"); printf("\t n|nonblocking - use nonblocking calls\n"); printf("\t v|verify - verify data\n"); exit(1); diff --git a/man/rstream.1 b/man/rstream.1 index ea87b951..29aa66bd 100644 --- a/man/rstream.1 +++ b/man/rstream.1 @@ -48,6 +48,8 @@ a | async - uses asynchronous operation (e.g. select / poll) .P b | blocking - uses blocking calls .P +f | fork - fork server processing (forces -T s option) +.P n | nonblocking - uses non-blocking calls .P v | verify - verifies data transfers -- 2.45.2