[PATCH] use montonic clock instead of gettimeofday

Tom Hughes Tom.Hughes at palm.com
Tue Dec 15 09:48:27 PST 2009


> 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.

Agreed.

> 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).

Yes, you're right on these.

I'm not going to resubmit that part of the patch, since the correct version has already been committed (ae24bb35e2ee3ecde990f55852982b573754ec43). :)

The first part of the patch was submitted as a bug here: https://bugs.freedesktop.org/show_bug.cgi?id=25624

Tom
________________________________________
From: Joerg.Barfurth at sun.com [Joerg.Barfurth at sun.com] On Behalf Of Joerg Barfurth [jub at sun.com]
Sent: Tuesday, December 15, 2009 12:55 AM
To: Tom Hughes
Cc: dbus at lists.freedesktop.org
Subject: Re: [PATCH] use montonic clock instead of gettimeofday

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