diff options
author | Ed Swierk <eswierk@aristanetworks.com> | 2009-07-23 14:13:34 -0700 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-07-27 14:09:15 -0500 |
commit | bf73f39649a12e03e8aa0c49b193ab78ef253b5c (patch) | |
tree | 70855b52e113a80e01fa7c51364bac483be1bde2 /slirp.c | |
parent | 1f9c6ef318bfd896a2a5afc728cd5a586ecf8bfb (diff) | |
download | slirp-bf73f39649a12e03e8aa0c49b193ab78ef253b5c.zip slirp-bf73f39649a12e03e8aa0c49b193ab78ef253b5c.tar.gz slirp-bf73f39649a12e03e8aa0c49b193ab78ef253b5c.tar.bz2 |
slirp: Use monotonic clock if available (v2)
Calling gettimeofday() to compute a time interval can cause problems if
the system clock jumps forwards or backwards; replace updtime() with
qemu_get_clock(rt_clock), which calls clock_gettime(CLOCK_MONOTONIC) if
it is available.
Also remove some useless macros.
Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'slirp.c')
-rw-r--r-- | slirp.c | 27 |
1 files changed, 2 insertions, 25 deletions
@@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" +#include "qemu-timer.h" #include "qemu-char.h" #include "slirp.h" #include "hw/hw.h" @@ -248,29 +249,6 @@ void slirp_cleanup(Slirp *slirp) if (nfds < (x)) \ nfds = (x) -/* - * curtime kept to an accuracy of 1ms - */ -#ifdef _WIN32 -static void updtime(void) -{ - struct _timeb tb; - - _ftime(&tb); - - curtime = tb.time * 1000 + tb.millitm; -} -#else -static void updtime(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - - curtime = tv.tv_sec * 1000 + tv.tv_usec / 1000; -} -#endif - void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds) { @@ -409,8 +387,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, global_writefds = writefds; global_xfds = xfds; - /* Update time */ - updtime(); + curtime = qemu_get_clock(rt_clock); TAILQ_FOREACH(slirp, &slirp_instances, entry) { |