[PATCH libinput 5/5] timer: Complain if a timer is set more then 5 seconds from now

Peter Hutterer peter.hutterer at who-t.net
Tue Jun 24 18:30:22 PDT 2014


On Tue, Jun 24, 2014 at 04:23:13PM +0200, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>

Did some minor changes before merging:
* two typos fixed s/then/than/ in 2/5 and this one
* adding timer->libinput as first arg to log_* in this patch, I merged it on
  top of the per-context log handlers

otherwise all five merged, thanks.

Cheers,
   Peter

> ---
>  src/timer.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/src/timer.c b/src/timer.c
> index 65fdd17..4f465f3 100644
> --- a/src/timer.c
> +++ b/src/timer.c
> @@ -22,6 +22,7 @@
>  
>  #include <assert.h>
>  #include <errno.h>
> +#include <inttypes.h>
>  #include <string.h>
>  #include <sys/timerfd.h>
>  #include <unistd.h>
> @@ -65,6 +66,20 @@ libinput_timer_arm_timer_fd(struct libinput *libinput)
>  void
>  libinput_timer_set(struct libinput_timer *timer, uint64_t expire)
>  {
> +#ifndef NDEBUG
> +	struct timespec ts;
> +
> +	if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
> +		uint64_t now = ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000;
> +		if (abs(expire - now) > 5000)
> +			log_bug_libinput("timer offset more then 5s, now %"
> +					 PRIu64 " expire %" PRIu64 "\n",
> +					 now, expire);
> +	} else {
> +		log_error("clock_gettime error: %s\n", strerror(errno));
> +	}
> +#endif
> +
>  	assert(expire);
>  
>  	if (!timer->expire)
> -- 
> 2.0.0
 


More information about the wayland-devel mailing list