timeval: Use monotonic time in OVS Python timeval library.
authorRyan Wilson <wryan@nicira.com>
Fri, 30 May 2014 22:38:51 +0000 (15:38 -0700)
committerEthan Jackson <ethan@nicira.com>
Fri, 30 May 2014 22:43:43 +0000 (15:43 -0700)
commit8396f8070bb35006fcd14486296fb203646a8dfa
treef1084072d3c1a2ced9407fd7f0ff3abcb1b19d5a
parent1481a7551da6893c08fb93bee9ac8293b90aa6a6
timeval: Use monotonic time in OVS Python timeval library.

Python's time.time() function uses the system wall clock. However,
if NTP resets the wall clock to be a time in the past, then this
causes any applications that poll block based on time, such as
ovs-xapi-sync, to poll block indefinitely since the time is
unexpectedly negative.

This patch fixes the issue by using time.monotonic() if Python's
version >= 3.3. Otherwise, the timeval module calls out to the
librt C shared library and uses the clock_gettime function with
CLOCK_MONOTONIC.

Note this is only enabled on Linux-based platforms. This has been
tested on Ubuntu 12.04 and Redhat 6.4.

Bug #1189434
Signed-off-by: Ryan Wilson <wryan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
python/ovs/timeval.py