[Patch 01/02] mieq threading prep: Only increment tail (push) when the event data is actually in the queue

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Nov 17 11:32:05 PST 2008


mi: Only increment tail (push) when the event data is actually in the  
queue

We don't want to increment tail until the data is already in place since
mieqProcessInputEvents assumes the data to be there if tail is  
incremented.

Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
---
  mi/mieq.c |    7 +++----
  1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/mi/mieq.c b/mi/mieq.c
index 52bb841..7437966 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -122,7 +122,7 @@ mieqResizeEvents(int min_size)
  void
  mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
  {
-    unsigned int           oldtail = miEventQueue.tail, newtail;
+    unsigned int           oldtail = miEventQueue.tail;
      EventListPtr           evt;
      int                    isMotion = 0;
      int                    evlen;
@@ -170,11 +170,10 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
      }
      else {
  	static int stuck = 0;
-	newtail = (oldtail + 1) % QUEUE_SIZE;
  	/* Toss events which come in late.  Usually this means your server's
           * stuck in an infinite loop somewhere, but SIGIO is still  
getting
           * handled. */
-	if (newtail == miEventQueue.head) {
+	if (((oldtail + 1) % QUEUE_SIZE) == miEventQueue.head) {
              ErrorF("[mi] EQ overflowing. The server is probably  
stuck "
                     "in an infinite loop.\n");
  	    if (!stuck) {
@@ -184,7 +183,6 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
  	    return;
          }
  	stuck = 0;
-	miEventQueue.tail = newtail;
      }

      evlen = sizeof(xEvent);
@@ -218,6 +216,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
      miEventQueue.events[oldtail].pDev = pDev;

      miEventQueue.lastMotion = isMotion;
+    miEventQueue.tail = (oldtail + 1) % QUEUE_SIZE;
  }

  void
-- 
1.6.0.3


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3221 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20081117/b6e03928/attachment.bin>


More information about the xorg mailing list