[PATCH 3/8] xf86Xinput.c: get DIX event queue pointer once at InitInput time

Keith Packard keithp at keithp.com
Thu Sep 17 18:14:33 PDT 2009


The DIX event queue is allocated before InitInput is called, so fetch
the pointer there and not randomly at other times. This avoids failing
to fetch the pointer sometimes during server regen and then smashing
memory through the stale pointer from the previous server generation.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/xfree86/common/xf86Init.c   |    2 ++
 hw/xfree86/common/xf86Xinput.c |    9 ---------
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index c9a05d8..527ede8 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1112,6 +1112,8 @@ InitInput(int argc, char **argv)
 
     mieqInit();
 
+    GetEventList(&xf86Events);
+
     /* Call the PreInit function for each input device instance. */
     for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
         /* Replace obsolete keyboard driver with kbd */
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 3543811..3adf18a 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -283,11 +283,6 @@ xf86ProcessCommonOptions(LocalDevicePtr local,
 
     /* Backwards compatibility. */
     local->history_size = GetMotionHistorySize();
-    /* Preallocate xEvent store */
-    if (!xf86Events)
-        GetEventList(&xf86Events);
-    if (!xf86Events)
-        FatalError("Couldn't allocate event store\n");
 }
 
 /***********************************************************************
@@ -769,7 +764,6 @@ xf86PostMotionEventP(DeviceIntPtr	device,
     }
 #endif
 
-    GetEventList(&xf86Events);
     nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
                                flags, first_valuator, num_valuators,
                                valuators);
@@ -819,7 +813,6 @@ xf86PostProximityEventP(DeviceIntPtr	device,
 
     XI_VERIFY_VALUATORS(num_valuators);
 
-    GetEventList(&xf86Events);
     nevents = GetProximityEvents(xf86Events, device,
                                  is_in ? ProximityIn : ProximityOut, 
                                  first_valuator, num_valuators, valuators);
@@ -881,7 +874,6 @@ xf86PostButtonEventP(DeviceIntPtr	device,
     }
 #endif
 
-    GetEventList(&xf86Events);
     nevents = GetPointerEvents(xf86Events, device,
                                is_down ? ButtonPress : ButtonRelease, button,
                                flags, first_valuator, num_valuators, valuators);
@@ -940,7 +932,6 @@ xf86PostKeyEventP(DeviceIntPtr	device,
     XI_VERIFY_VALUATORS(num_valuators);
 
     if (is_absolute) {
-        GetEventList(&xf86Events);
         nevents = GetKeyboardValuatorEvents(xf86Events, device,
                                             is_down ? KeyPress : KeyRelease,
                                             key_code, first_valuator,
-- 
1.6.3.3



More information about the xorg-devel mailing list