[PATCH 4/5] xfree86: Reduce SIGIO block/unblock traffic

Adam Jackson ajax at redhat.com
Thu Dec 16 12:31:39 PST 2010


Push/pop the SIGIO block outside the loop rather than every time through
it.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/xfree86/common/xf86Events.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 84c0d18..6561292 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -250,11 +250,12 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
 
 	XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
 	if (XFD_ANYSET(&devicesWithInput)) {
+	    int sigstate = xf86BlockSIGIO();
 	    pInfo = xf86InputDevs;
+
 	    while (pInfo) {
 		if (pInfo->read_input && pInfo->fd >= 0 &&
 		    (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
-		    int sigstate = xf86BlockSIGIO();
 
 		    /*
 		     * Remove the descriptior from the set because more than one
@@ -263,10 +264,10 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
 		    FD_CLR(pInfo->fd, &devicesWithInput);
 
 		    pInfo->read_input(pInfo);
-		    xf86UnblockSIGIO(sigstate);
 		}
 		pInfo = pInfo->next;
 	    }
+	    xf86UnblockSIGIO(sigstate);
 	}
     }
 
@@ -394,17 +395,17 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
      * are reenabled.
      */
 
+    sigstate = xf86BlockSIGIO ();
     for (i = keyc->xkbInfo->desc->min_key_code;
          i < keyc->xkbInfo->desc->max_key_code;
          i++) {
         if (key_is_down(pDev, i, KEY_POSTED)) {
-            sigstate = xf86BlockSIGIO ();
             nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
             for (j = 0; j < nevents; j++)
                 mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
-            xf86UnblockSIGIO(sigstate);
         }
     }
+    xf86UnblockSIGIO(sigstate);
 }
 
 /*
-- 
1.7.3.2



More information about the xorg-devel mailing list