1
1

Run -i interval timers on the server as well as the client.

Этот коммит содержится в:
Jef Poskanzer 2013-11-01 13:59:33 -07:00
родитель 9019e92411
Коммит 38917b1f3f
3 изменённых файлов: 84 добавлений и 8 удалений

Просмотреть файл

@ -550,8 +550,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
case 'i':
/* XXX: could potentially want separate stat collection and reporting intervals,
but just set them to be the same for now */
test->stats_interval = atof(optarg);
test->reporter_interval = atof(optarg);
test->stats_interval = test->reporter_interval = atof(optarg);
if (test->stats_interval > MAX_INTERVAL) {
i_errno = IEINTERVAL;
return -1;

Просмотреть файл

@ -64,23 +64,25 @@ test_timer_proc(TimerClientData client_data, struct timeval *nowP)
}
static void
stats_timer_proc(TimerClientData client_data, struct timeval *nowP)
client_stats_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;
if (test->done)
return;
test->stats_callback(test);
if (test->stats_callback)
test->stats_callback(test);
}
static void
reporter_timer_proc(TimerClientData client_data, struct timeval *nowP)
client_reporter_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;
if (test->done)
return;
test->reporter_callback(test);
if (test->reporter_callback)
test->reporter_callback(test);
}
static int
@ -104,14 +106,14 @@ create_client_timers(struct iperf_test * test)
}
}
if (test->stats_interval != 0) {
test->stats_timer = tmr_create(&now, stats_timer_proc, cd, test->stats_interval * SEC_TO_US, 1);
test->stats_timer = tmr_create(&now, client_stats_timer_proc, cd, test->stats_interval * SEC_TO_US, 1);
if (test->stats_timer == NULL) {
i_errno = IEINITTEST;
return -1;
}
}
if (test->reporter_interval != 0) {
test->reporter_timer = tmr_create(&now, reporter_timer_proc, cd, test->reporter_interval * SEC_TO_US, 1);
test->reporter_timer = tmr_create(&now, client_reporter_timer_proc, cd, test->reporter_interval * SEC_TO_US, 1);
if (test->reporter_timer == NULL) {
i_errno = IEINITTEST;
return -1;

Просмотреть файл

@ -284,6 +284,57 @@ iperf_test_reset(struct iperf_test *test)
memset(test->cookie, 0, COOKIE_SIZE);
}
static void
server_stats_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;
if (test->done)
return;
if (test->stats_callback)
test->stats_callback(test);
}
static void
server_reporter_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;
if (test->done)
return;
if (test->reporter_callback)
test->reporter_callback(test);
}
static int
create_server_timers(struct iperf_test * test)
{
struct timeval now;
TimerClientData cd;
if (gettimeofday(&now, NULL) < 0) {
i_errno = IEINITTEST;
return -1;
}
cd.p = test;
test->stats_timer = test->reporter_timer = NULL;
if (test->stats_interval != 0) {
test->stats_timer = tmr_create(&now, server_stats_timer_proc, cd, test->stats_interval * SEC_TO_US, 1);
if (test->stats_timer == NULL) {
i_errno = IEINITTEST;
return -1;
}
}
if (test->reporter_interval != 0) {
test->reporter_timer = tmr_create(&now, server_reporter_timer_proc, cd, test->reporter_interval * SEC_TO_US, 1);
if (test->reporter_timer == NULL) {
i_errno = IEINITTEST;
return -1;
}
}
return 0;
}
static void
server_omit_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
@ -294,6 +345,12 @@ server_omit_timer_proc(TimerClientData client_data, struct timeval *nowP)
iperf_reset_stats(test);
if (test->verbose && !test->json_output && test->reporter_interval == 0)
printf("Finished omit period, starting real test\n");
/* Reset the timers. */
if (test->stats_timer != NULL)
tmr_reset(nowP, test->stats_timer);
if (test->reporter_timer != NULL)
tmr_reset(nowP, test->reporter_timer);
}
static int
@ -328,6 +385,20 @@ cleanup_server(struct iperf_test *test)
/* Close open test sockets */
close(test->ctrl_sck);
close(test->listener);
/* Cancel any remaining timers. */
if (test->stats_timer != NULL) {
tmr_cancel(test->stats_timer);
test->stats_timer = NULL;
}
if (test->reporter_timer != NULL) {
tmr_cancel(test->reporter_timer);
test->reporter_timer = NULL;
}
if (test->omit_timer != NULL) {
tmr_cancel(test->omit_timer);
test->omit_timer = NULL;
}
}
@ -463,6 +534,10 @@ iperf_run_server(struct iperf_test *test)
cleanup_server(test);
return -1;
}
if (create_server_timers(test) < 0) {
cleanup_server(test);
return -1;
}
if (create_server_omit_timer(test) < 0) {
cleanup_server(test);
return -1;