Performance improvements.
Этот коммит содержится в:
родитель
37ba3f73dd
Коммит
7bcbb1f653
@ -772,10 +772,13 @@ iperf_check_throttle(struct iperf_stream *sp, struct timeval *nowP)
|
||||
|
||||
seconds = timeval_diff(&sp->result->start_time, nowP);
|
||||
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;
|
||||
else
|
||||
FD_SET(sp->socket, &sp->test->write_set);
|
||||
} else {
|
||||
sp->green_light = 0;
|
||||
FD_CLR(sp->socket, &sp->test->write_set);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -319,9 +319,10 @@ iperf_run_client(struct iperf_test * test)
|
||||
int startup;
|
||||
#define CM_SELECT 1
|
||||
#define CM_SIGALRM 2
|
||||
int result;
|
||||
int result = 0;
|
||||
fd_set read_set, write_set;
|
||||
struct timeval now;
|
||||
struct timeval* timeout = NULL;
|
||||
|
||||
/* Termination signals. */
|
||||
iperf_catch_sigend(sigend_handler);
|
||||
@ -355,13 +356,14 @@ iperf_run_client(struct iperf_test * test)
|
||||
|
||||
startup = 1;
|
||||
concurrency_model = CM_SELECT; /* always start in select mode */
|
||||
(void) gettimeofday(&now, NULL);
|
||||
while (test->state != IPERF_DONE) {
|
||||
|
||||
if (concurrency_model == CM_SELECT) {
|
||||
memcpy(&read_set, &test->read_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) {
|
||||
i_errno = IESELECT;
|
||||
return -1;
|
||||
@ -402,17 +404,17 @@ iperf_run_client(struct iperf_test * test)
|
||||
|
||||
if (test->reverse) {
|
||||
// Reverse mode. Client receives.
|
||||
if (iperf_recv(test, &read_set) < 0) {
|
||||
if (iperf_recv(test, &read_set) < 0)
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
/* Run the timers. */
|
||||
(void) gettimeofday(&now, NULL);
|
||||
|
@ -417,6 +417,7 @@ iperf_run_server(struct iperf_test *test)
|
||||
fd_set read_set, write_set;
|
||||
struct iperf_stream *sp;
|
||||
struct timeval now;
|
||||
struct timeval* timeout;
|
||||
|
||||
/* Termination signals. */
|
||||
iperf_catch_sigend(sigend_handler);
|
||||
@ -452,13 +453,14 @@ iperf_run_server(struct iperf_test *test)
|
||||
test->state = IPERF_START;
|
||||
streams_accepted = 0;
|
||||
|
||||
(void) gettimeofday(&now, NULL);
|
||||
while (test->state != IPERF_DONE) {
|
||||
|
||||
memcpy(&read_set, &test->read_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) {
|
||||
cleanup_server(test);
|
||||
i_errno = IESELECT;
|
||||
@ -570,9 +572,12 @@ iperf_run_server(struct iperf_test *test)
|
||||
}
|
||||
}
|
||||
|
||||
/* Run the timers. */
|
||||
(void) gettimeofday(&now, NULL);
|
||||
tmr_run(&now);
|
||||
if (result == 0 ||
|
||||
(timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0)) {
|
||||
/* Run the timers. */
|
||||
(void) gettimeofday(&now, NULL);
|
||||
tmr_run(&now);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user