[PATCH 4/5] Use current time for event timestamps

Peter Hutterer peter.hutterer at who-t.net
Thu Apr 12 22:27:50 PDT 2012


On Wed, Apr 11, 2012 at 11:22:13AM -0700, Chase Douglas wrote:
> During testing I was able to cause a pointer grab replay to fail by
> sending a lot of events at once on a beefy machine. The brab replay

typo, "grab"

> request time was equal to the event stamp time, but both were later
> than currentTime. This means it is somehow possible to generate events,
> send them to a client, and have the client make a request based on those
> events all before the server time is updated.

I wonder if this could be as simple as a missing UpdateCurrentTime() in
AllowSome() or at the very least the need to call UpdateCurrentTime() before
converting client time to server time in the Proc*AllowEvents.

Cheers,
  Peter

> 
> This commit changes the event timestamp generation to use the server
> currentTime instead of getting a fresh time from the system. We don't
> really guarantee timestamps that are precise to the millisecond level,
> so this shouldn't be a big issue.
> 
> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
> ---
>  dix/getevents.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/dix/getevents.c b/dix/getevents.c
> index 3093786..569886b 100644
> --- a/dix/getevents.c
> +++ b/dix/getevents.c
> @@ -260,7 +260,7 @@ CreateClassesChangedEvent(InternalEvent *event,
>  {
>      int i;
>      DeviceChangedEvent *dce;
> -    CARD32 ms = GetTimeInMillis();
> +    CARD32 ms = currentTime.milliseconds;
>  
>      dce = &event->changed_event;
>      memset(dce, 0, sizeof(DeviceChangedEvent));
> @@ -1070,7 +1070,7 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
>              return 0;
>      }
>  
> -    ms = GetTimeInMillis();
> +    ms = currentTime.milliseconds;
>  
>      raw = &events->raw_event;
>      events++;
> @@ -1511,7 +1511,7 @@ int
>  GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
>                   int buttons, int flags, const ValuatorMask *mask_in)
>  {
> -    CARD32 ms = GetTimeInMillis();
> +    CARD32 ms = currentTime.milliseconds;
>      int num_events = 0, nev_tmp;
>      ValuatorMask mask;
>      ValuatorMask scroll;
> @@ -1688,7 +1688,7 @@ GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
>          UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
>  
>      event = &events->device_event;
> -    init_device_event(event, pDev, GetTimeInMillis());
> +    init_device_event(event, pDev, currentTime.milliseconds);
>      event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
>  
>      clipValuators(pDev, &mask);
> @@ -1705,7 +1705,7 @@ GetTouchOwnershipEvents(InternalEvent *events, DeviceIntPtr pDev,
>  {
>      TouchClassPtr t = pDev->touch;
>      TouchOwnershipEvent *event;
> -    CARD32 ms = GetTimeInMillis();
> +    CARD32 ms = currentTime.milliseconds;
>  
>      if (!pDev->enabled || !t || !ti)
>          return 0;
> @@ -1770,7 +1770,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
>      TouchClassPtr t = dev->touch;
>      ValuatorClassPtr v = dev->valuator;
>      DeviceEvent *event;
> -    CARD32 ms = GetTimeInMillis();
> +    CARD32 ms = currentTime.milliseconds;
>      ValuatorMask mask;
>      double screenx = 0.0, screeny = 0.0;        /* desktop coordinate system */
>      double devx = 0.0, devy = 0.0;      /* desktop-wide in device coords */
> -- 
> 1.7.9.1
> 


More information about the xorg-devel mailing list