From 037c0c236741633b6dc4c61730f814cc92d27f55 Mon Sep 17 00:00:00 2001 From: Jef Poskanzer Date: Mon, 18 Feb 2013 09:06:50 -0800 Subject: [PATCH] Handle timers longer than 2147 seconds (2^31 microseconds). --- src/iperf_api.c | 6 +++--- src/timer.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 05f881e..2d21106 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -681,20 +681,20 @@ iperf_init_test(struct iperf_test *test) if (test->settings->bytes == 0) { test->done = 0; cd.p = test; - test->timer = tmr_create(&now, test_timer_proc, cd, test->duration * SEC_TO_US, 0); + test->timer = tmr_create(&now, test_timer_proc, cd, (int64_t) test->duration * SEC_TO_US, 0); if (test->timer == NULL) return -1; } if (test->stats_interval != 0) { cd.p = test; - test->stats_timer = tmr_create(&now, stats_timer_proc, cd, test->stats_interval * SEC_TO_US, 1); + test->stats_timer = tmr_create(&now, stats_timer_proc, cd, (int64_t) test->stats_interval * SEC_TO_US, 1); if (test->stats_timer == NULL) return -1; } if (test->reporter_interval != 0) { cd.p = test; - test->reporter_timer = tmr_create(&now, reporter_timer_proc, cd, test->reporter_interval * SEC_TO_US, 1); + test->reporter_timer = tmr_create(&now, reporter_timer_proc, cd, (int64_t) test->reporter_interval * SEC_TO_US, 1); if (test->reporter_timer == NULL) return -1; } diff --git a/src/timer.c b/src/timer.c index eb1e7ed..4552571 100644 --- a/src/timer.c +++ b/src/timer.c @@ -159,12 +159,12 @@ tmr_timeout( struct timeval* nowP ) /* Since the list is sorted, we only need to look at the first timer. */ if ( timers == NULL ) return NULL; - usecs = ( timers->time.tv_sec - now.tv_sec ) * 1000000L + + usecs = ( timers->time.tv_sec - now.tv_sec ) * 1000000LL + ( timers->time.tv_usec - now.tv_usec ); if ( usecs <= 0 ) usecs = 0; - timeout.tv_sec = usecs / 1000000L; - timeout.tv_usec = usecs % 1000000L; + timeout.tv_sec = usecs / 1000000LL; + timeout.tv_usec = usecs % 1000000LL; return &timeout; }