[PATCH] use montonic clock instead of gettimeofday
Joerg Barfurth
jub at sun.com
Tue Dec 15 00:55:51 PST 2009
Tom Hughes schrieb:
> Greetings,
>
Greetings. Just noticed this patch.
> Attached is a patch to use the monotonic clock instead of gettimeofday()
> in _dbus_get_current_time(), which prevents issues when
> _dbus_get_current_time() is used to calculate timeouts and the system
> time changes (e.g., in _dbus_connection_block_pending_call()).
>
IMHO you should update the documentation for _dbus_get_current_time or,
even better, rename it to reflect the new semantics. It does not return
'current' time as in gettimeofday any more, because the meaning of
absolute time values is now unspecified.
If this function is used in DBus for anything other than elapsed time or
timeout calculations, the old version would need to be kept as well.
> It also contains a patch for pthread_cond_timedwait to use the monotonic
> clock, but this appears to have already been fixed, so you can ignore
> that part of the patch.
>
That part of the patch certainly looks broken. The
pthread_condattr_setclock() would need to come after
pthread_condattr_init().
And further below the new end_time.tv_nsec calculation is completely off
(by 3 to 6 orders of magnitude).
Regards
- Jörg B
More information about the dbus
mailing list