Performance improvements.
This commit is contained in:
parent
37ba3f73dd
commit
7bcbb1f653
@ -772,10 +772,13 @@ iperf_check_throttle(struct iperf_stream *sp, struct timeval *nowP)
|
|||||||
|
|
||||||
seconds = timeval_diff(&sp->result->start_time, nowP);
|
seconds = timeval_diff(&sp->result->start_time, nowP);
|
||||||
bits_per_second = sp->result->bytes_sent * 8 / seconds;
|
bits_per_second = sp->result->bytes_sent * 8 / seconds;
|
||||||
if (bits_per_second < sp->test->settings->rate)
|
if (bits_per_second < sp->test->settings->rate) {
|
||||||
sp->green_light = 1;
|
sp->green_light = 1;
|
||||||
else
|
FD_SET(sp->socket, &sp->test->write_set);
|
||||||
|
} else {
|
||||||
sp->green_light = 0;
|
sp->green_light = 0;
|
||||||
|
FD_CLR(sp->socket, &sp->test->write_set);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -319,9 +319,10 @@ iperf_run_client(struct iperf_test * test)
|
|||||||
int startup;
|
int startup;
|
||||||
#define CM_SELECT 1
|
#define CM_SELECT 1
|
||||||
#define CM_SIGALRM 2
|
#define CM_SIGALRM 2
|
||||||
int result;
|
int result = 0;
|
||||||
fd_set read_set, write_set;
|
fd_set read_set, write_set;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
struct timeval* timeout = NULL;
|
||||||
|
|
||||||
/* Termination signals. */
|
/* Termination signals. */
|
||||||
iperf_catch_sigend(sigend_handler);
|
iperf_catch_sigend(sigend_handler);
|
||||||
@ -355,13 +356,14 @@ iperf_run_client(struct iperf_test * test)
|
|||||||
|
|
||||||
startup = 1;
|
startup = 1;
|
||||||
concurrency_model = CM_SELECT; /* always start in select mode */
|
concurrency_model = CM_SELECT; /* always start in select mode */
|
||||||
(void) gettimeofday(&now, NULL);
|
|
||||||
while (test->state != IPERF_DONE) {
|
while (test->state != IPERF_DONE) {
|
||||||
|
|
||||||
if (concurrency_model == CM_SELECT) {
|
if (concurrency_model == CM_SELECT) {
|
||||||
memcpy(&read_set, &test->read_set, sizeof(fd_set));
|
memcpy(&read_set, &test->read_set, sizeof(fd_set));
|
||||||
memcpy(&write_set, &test->write_set, sizeof(fd_set));
|
memcpy(&write_set, &test->write_set, sizeof(fd_set));
|
||||||
result = select(test->max_fd + 1, &read_set, &write_set, NULL, tmr_timeout(&now));
|
(void) gettimeofday(&now, NULL);
|
||||||
|
timeout = tmr_timeout(&now);
|
||||||
|
result = select(test->max_fd + 1, &read_set, &write_set, NULL, timeout);
|
||||||
if (result < 0 && errno != EINTR) {
|
if (result < 0 && errno != EINTR) {
|
||||||
i_errno = IESELECT;
|
i_errno = IESELECT;
|
||||||
return -1;
|
return -1;
|
||||||
@ -402,17 +404,17 @@ iperf_run_client(struct iperf_test * test)
|
|||||||
|
|
||||||
if (test->reverse) {
|
if (test->reverse) {
|
||||||
// Reverse mode. Client receives.
|
// Reverse mode. Client receives.
|
||||||
if (iperf_recv(test, &read_set) < 0) {
|
if (iperf_recv(test, &read_set) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Regular mode. Client sends.
|
// Regular mode. Client sends.
|
||||||
if (iperf_send(test, concurrency_model == CM_SIGALRM ? NULL : &write_set) < 0) {
|
if (iperf_send(test, concurrency_model == CM_SIGALRM ? NULL : &write_set) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (concurrency_model == CM_SELECT ||
|
if ((concurrency_model == CM_SELECT &&
|
||||||
|
(result == 0 ||
|
||||||
|
(timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0))) ||
|
||||||
(concurrency_model == CM_SIGALRM && sigalrm_triggered)) {
|
(concurrency_model == CM_SIGALRM && sigalrm_triggered)) {
|
||||||
/* Run the timers. */
|
/* Run the timers. */
|
||||||
(void) gettimeofday(&now, NULL);
|
(void) gettimeofday(&now, NULL);
|
||||||
|
@ -417,6 +417,7 @@ iperf_run_server(struct iperf_test *test)
|
|||||||
fd_set read_set, write_set;
|
fd_set read_set, write_set;
|
||||||
struct iperf_stream *sp;
|
struct iperf_stream *sp;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
struct timeval* timeout;
|
||||||
|
|
||||||
/* Termination signals. */
|
/* Termination signals. */
|
||||||
iperf_catch_sigend(sigend_handler);
|
iperf_catch_sigend(sigend_handler);
|
||||||
@ -452,13 +453,14 @@ iperf_run_server(struct iperf_test *test)
|
|||||||
test->state = IPERF_START;
|
test->state = IPERF_START;
|
||||||
streams_accepted = 0;
|
streams_accepted = 0;
|
||||||
|
|
||||||
(void) gettimeofday(&now, NULL);
|
|
||||||
while (test->state != IPERF_DONE) {
|
while (test->state != IPERF_DONE) {
|
||||||
|
|
||||||
memcpy(&read_set, &test->read_set, sizeof(fd_set));
|
memcpy(&read_set, &test->read_set, sizeof(fd_set));
|
||||||
memcpy(&write_set, &test->write_set, sizeof(fd_set));
|
memcpy(&write_set, &test->write_set, sizeof(fd_set));
|
||||||
|
|
||||||
result = select(test->max_fd + 1, &read_set, &write_set, NULL, tmr_timeout(&now));
|
(void) gettimeofday(&now, NULL);
|
||||||
|
timeout = tmr_timeout(&now);
|
||||||
|
result = select(test->max_fd + 1, &read_set, &write_set, NULL, timeout);
|
||||||
if (result < 0 && errno != EINTR) {
|
if (result < 0 && errno != EINTR) {
|
||||||
cleanup_server(test);
|
cleanup_server(test);
|
||||||
i_errno = IESELECT;
|
i_errno = IESELECT;
|
||||||
@ -570,9 +572,12 @@ iperf_run_server(struct iperf_test *test)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Run the timers. */
|
if (result == 0 ||
|
||||||
(void) gettimeofday(&now, NULL);
|
(timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0)) {
|
||||||
tmr_run(&now);
|
/* Run the timers. */
|
||||||
|
(void) gettimeofday(&now, NULL);
|
||||||
|
tmr_run(&now);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user