summaryrefslogtreecommitdiff
path: root/mi/mieq.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2009-01-11 16:10:45 -0800
committerJeremy Huddleston <jeremyhu@freedesktop.org>2009-01-11 16:39:20 -0800
commitdde5c591be74139ec6f2a90a3fdc7904d7342554 (patch)
tree823018d5126dbf406d589087bd8e64adbbc85f9c /mi/mieq.c
parent0720816aea20971ee94b5df3faa9cb9f16e93f82 (diff)
mieq: Avoid possible race condition whereby one thread might call mieqEnqueue before InitAndStartDevices finishes
This is more of a hack around the problem. This is something that will need to be addressed in a more structured manner with the multi threaded input efforts. (cherry picked from commit 3c596c061e75848cfa76dd9259c23a3f3a67444c)
Diffstat (limited to 'mi/mieq.c')
-rw-r--r--mi/mieq.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index d6b722de4..963f27c01 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -247,7 +247,14 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
evt->event->u.keyButtonPointer.time = miEventQueue.lastEventTime;
miEventQueue.lastEventTime = evt->event->u.keyButtonPointer.time;
- miEventQueue.events[oldtail].pScreen = EnqueueScreen(pDev);
+
+ /* Avoid possible crash when multithreaded and mieqEnqueue is called before
+ * InitAndStartDevices finishes.
+ */
+ if(pDev && pDev->spriteInfo && pDev->spriteInfo->sprite)
+ miEventQueue.events[oldtail].pScreen = EnqueueScreen(pDev);
+ else
+ miEventQueue.events[oldtail].pScreen = NULL;
miEventQueue.events[oldtail].pDev = pDev;
miEventQueue.lastMotion = isMotion;
@@ -403,7 +410,7 @@ mieqProcessInputEvents(void)
/* Custom event handler */
handler = miEventQueue.handlers[type];
- if (screen != DequeueScreen(dev) && !handler) {
+ if (screen && screen != DequeueScreen(dev) && !handler) {
/* Assumption - screen switching can only occur on motion events. */
DequeueScreen(dev) = screen;
x = event->u.keyButtonPointer.rootX;