xserver: Branch 'xorg-server-1.4-apple'

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Thu Oct 23 14:09:58 PDT 2008


 mi/mieq.c |   47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

New commits:
commit d7d4cd30039992548bc298c9366fa51a6441ac17
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Oct 23 14:08:30 2008 -0700

    mi: Avoid possible deadlock in miEq
    
    When the handler for an event requires sending a message to another thread that is waiting for the miEq mutex.

diff --git a/mi/mieq.c b/mi/mieq.c
index 3f50f27..543b7e7 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -231,7 +231,7 @@ mieqSetHandler(int event, mieqHandler handler)
 void
 mieqProcessInputEvents(void)
 {
-    EventRec *e = NULL;
+    EventRec e;
     int x = 0, y = 0;
     DeviceIntPtr dev = NULL;
 
@@ -250,45 +250,46 @@ mieqProcessInputEvents(void)
             DPMSSet(DPMSModeOn);
 #endif
 
-        e = &miEventQueue.events[miEventQueue.head];
+        memcpy(&e, &miEventQueue.events[miEventQueue.head], sizeof(EventRec));
         miEventQueue.head = (miEventQueue.head + 1) % QUEUE_SIZE;
 
-        if (miEventQueue.handlers[e->event->u.u.type]) {
+#ifdef XQUARTZ
+        pthread_mutex_unlock(&miEventQueueMutex);
+#endif
+
+        if (miEventQueue.handlers[e.event->u.u.type]) {
             /* If someone's registered a custom event handler, let them
              * steal it. */
-            miEventQueue.handlers[e->event->u.u.type](miEventQueue.pDequeueScreen->myNum,
-                                                      e->event, dev,
-                                                      e->nevents);
+            miEventQueue.handlers[e.event->u.u.type](e.pScreen->myNum,
+                                                      e.event, e.pDev,
+                                                      e.nevents);
         }
-        else if (e->pScreen != miEventQueue.pDequeueScreen) {
+        else if (e.pScreen != miEventQueue.pDequeueScreen) {
             /* Assumption - screen switching can only occur on motion events. */
-            miEventQueue.pDequeueScreen = e->pScreen;
-            x = e->event[0].u.keyButtonPointer.rootX;
-            y = e->event[0].u.keyButtonPointer.rootY;
-            NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
+            miEventQueue.pDequeueScreen = e.pScreen;
+            x = e.event[0].u.keyButtonPointer.rootX;
+            y = e.event[0].u.keyButtonPointer.rootY;
+            NewCurrentScreen(e.pScreen, x, y);
         }
         else {
             /* If this is a core event, make sure our keymap, et al, is
              * changed to suit. */
-            if (e->event[0].u.u.type == KeyPress ||
-                e->event[0].u.u.type == KeyRelease) {
-                SwitchCoreKeyboard(e->pDev);
+            if (e.event[0].u.u.type == KeyPress ||
+                e.event[0].u.u.type == KeyRelease) {
+                SwitchCoreKeyboard(e.pDev);
                 dev = inputInfo.keyboard;
             }
-            else if (e->event[0].u.u.type == MotionNotify ||
-                     e->event[0].u.u.type == ButtonPress ||
-                     e->event[0].u.u.type == ButtonRelease) {
-                SwitchCorePointer(e->pDev);
+            else if (e.event[0].u.u.type == MotionNotify ||
+                     e.event[0].u.u.type == ButtonPress ||
+                     e.event[0].u.u.type == ButtonRelease) {
+                SwitchCorePointer(e.pDev);
                 dev = inputInfo.pointer;
             }
             else {
-                dev = e->pDev;
+                dev = e.pDev;
             }
 
-            dev->public.processInputProc(e->event, dev, e->nevents);
+            dev->public.processInputProc(e.event, dev, e.nevents);
         }
     }
-#ifdef XQUARTZ
-    pthread_mutex_unlock(&miEventQueueMutex);
-#endif
 }


More information about the xorg-commit mailing list