Skip to content

Commit

Permalink
Close tests on that have have been running longer than test duration.
Browse files Browse the repository at this point in the history
- Iperf server now cancels tests that have been left running for longer than duration requested by the client. This can occur in cases where client has sudden network loss and control connection is left in lingering state.
  • Loading branch information
ekamikke committed Jan 12, 2015
1 parent 20bd2a6 commit aaeeaf6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/iperf_server_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ iperf_test_reset(struct iperf_test *test)
memset(test->cookie, 0, COOKIE_SIZE);
}

static void
server_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
struct iperf_test *test = client_data.p;

test->timer = NULL;
if (test->done)
return;
test->done = 1;
close(test->ctrl_sck);
}


static void
server_stats_timer_proc(TimerClientData client_data, struct timeval *nowP)
{
Expand Down Expand Up @@ -345,7 +358,16 @@ create_server_timers(struct iperf_test * test)
return -1;
}
cd.p = test;
test->stats_timer = test->reporter_timer = NULL;
test->timer = test->stats_timer = test->reporter_timer = NULL;
if (test->duration != 0 ) {
test->done = 0;
test->timer = tmr_create(&now, server_timer_proc, cd, (test->duration + test->omit + 5) * SEC_TO_US, 0);
if (test->timer == NULL) {
i_errno = IEINITTEST;
return -1;
}
}

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) {
Expand Down Expand Up @@ -427,6 +449,11 @@ cleanup_server(struct iperf_test *test)
tmr_cancel(test->omit_timer);
test->omit_timer = NULL;
}
if (test->timer != NULL) {
tmr_cancel(test->timer);
test->timer = NULL;
}

}


Expand Down

0 comments on commit aaeeaf6

Please sign in to comment.