From 04e07442bbc8a5d8515fa1eea52cb15ebd2cc992 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 31 Oct 2014 12:52:23 +0100 Subject: Use new get_tick_count() to avoid timing issues on packets --- src/usb-linux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/usb-linux.c') diff --git a/src/usb-linux.c b/src/usb-linux.c index 751b6ed..8acbace 100644 --- a/src/usb-linux.c +++ b/src/usb-linux.c @@ -34,6 +34,7 @@ #include "usb.h" #include "log.h" #include "device.h" +#include "utils.h" // interval for device connection/disconnection polling, in milliseconds // we need this because there is currently no asynchronous device discovery mechanism in libusb @@ -266,7 +267,7 @@ int usb_discover(void) usbmuxd_log(LL_FATAL, "Too many errors getting device list"); return cnt; } else { - gettimeofday(&next_dev_poll_time, NULL); + get_tick_count(&next_dev_poll_time); next_dev_poll_time.tv_usec += DEVICE_POLL_TIME * 1000; next_dev_poll_time.tv_sec += next_dev_poll_time.tv_usec / 1000000; next_dev_poll_time.tv_usec = next_dev_poll_time.tv_usec % 1000000; @@ -477,7 +478,7 @@ int usb_discover(void) libusb_free_device_list(devs, 1); - gettimeofday(&next_dev_poll_time, NULL); + get_tick_count(&next_dev_poll_time); next_dev_poll_time.tv_usec += DEVICE_POLL_TIME * 1000; next_dev_poll_time.tv_sec += next_dev_poll_time.tv_usec / 1000000; next_dev_poll_time.tv_usec = next_dev_poll_time.tv_usec % 1000000; @@ -538,7 +539,7 @@ static int dev_poll_remain_ms(void) struct timeval tv; if(!device_polling) return 100000; // devices will never be polled if this is > 0 - gettimeofday(&tv, NULL); + get_tick_count(&tv); msecs = (next_dev_poll_time.tv_sec - tv.tv_sec) * 1000; msecs += (next_dev_poll_time.tv_usec - tv.tv_usec) / 1000; if(msecs < 0) @@ -595,7 +596,7 @@ int usb_process_timeout(int msec) { int res; struct timeval tleft, tcur, tfin; - gettimeofday(&tcur, NULL); + get_tick_count(&tcur); tfin.tv_sec = tcur.tv_sec + (msec / 1000); tfin.tv_usec = tcur.tv_usec + (msec % 1000) * 1000; tfin.tv_sec += tfin.tv_usec / 1000000; @@ -614,7 +615,7 @@ int usb_process_timeout(int msec) } // reap devices marked dead due to an RX error reap_dead_devices(); - gettimeofday(&tcur, NULL); + get_tick_count(&tcur); } return 0; } -- cgit v1.1-32-gdbae