Pushing out merge of inadvertent branch.

This commit is contained in:
Jef Poskanzer 2013-12-02 09:55:48 -08:00
commit e41823c46b
6 changed files with 21 additions and 6 deletions

View File

@ -57,6 +57,9 @@ show a help synopsis
.TP
.BR -s ", " --server " "
run in server mode
.TP
.BR -D ", " --daemon " "
run the server in background as a daemon
.SH "CLIENT SPECIFIC OPTIONS"
.TP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2011, The Regents of the University of California,
* Copyright (c) 2009-2013, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
@ -536,7 +536,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
blksize = 0;
server_flag = client_flag = rate_flag = 0;
while ((flag = getopt_long(argc, argv, "p:f:i:DVJdvsc:ub:t:n:l:P:Rw:B:M:N46S:L:ZO:F:A:T:h", longopts, NULL)) != -1) {
while ((flag = getopt_long(argc, argv, "p:f:i:DVJvsc:ub:t:n:l:P:Rw:B:M:N46S:L:ZO:F:A:T:h", longopts, NULL)) != -1) {
switch (flag) {
case 'p':
test->server_port = atoi(optarg);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2011, The Regents of the University of California,
* Copyright (c) 2009-2013, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
@ -273,6 +273,7 @@ enum {
IESETWINDOWSIZE = 130, // Unable to set socket window size (check perror)
IEPROTOCOL = 131, // Protocol does not exist
IEAFFINITY = 132, // Unable to set CPU affinity (check perror)
IEDAEMON = 133, // Unable to become a daemon process
/* Stream errors */
IECREATESTREAM = 200, // Unable to create a new stream (check herror/perror)
IEINITSTREAM = 201, // Unable to initialize stream (check herror/perror)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2011, The Regents of the University of California,
* Copyright (c) 2009-2013, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
@ -235,6 +235,10 @@ iperf_strerror(int i_errno)
snprintf(errstr, len, "unable to set CPU affinity");
perr = 1;
break;
case IEDAEMON:
snprintf(errstr, len, "unable to become a daemon");
perr = 1;
break;
case IECREATESTREAM:
snprintf(errstr, len, "unable to create a new stream");
herr = 1;

View File

@ -80,6 +80,7 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n"
" -h, --help show this message and quit\n"
"Server specific:\n"
" -s, --server run in server mode\n"
" -D, --daemon run the server as a daemon\n"
"Client specific:\n"
" -c, --client <host> run in client mode, connecting to <host>\n"
" -u, --udp use UDP rather than TCP\n"
@ -104,7 +105,6 @@ const char usage_longstr[] = "Usage: iperf [-s|-c host] [options]\n"
" -T, --title str prefix every output line with this string\n"
#ifdef NOT_YET_SUPPORTED /* still working on these */
" -D, --daemon run the server as a daemon\n"
#endif
"\n"

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2011, The Regents of the University of California,
* Copyright (c) 2009-2013, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
@ -104,6 +104,13 @@ run(struct iperf_test *test)
switch (test->role) {
case 's':
if (test->daemon) {
int rc = daemon(0, 0);
if (rc < 0) {
i_errno = IEDAEMON;
iperf_errexit(test, "error - %s", iperf_strerror(i_errno));
}
}
consecutive_errors = 0;
for (;;) {
if (iperf_run_server(test) < 0) {