[gnome-session] gsm: Fix race condition in idle monitor



commit 861313503a741f0129611ca005cf6d7c27124b54
Author: Christopher Halse Rogers <chalserogers gmail com>
Date:   Thu May 26 11:09:14 2011 +0200

    gsm: Fix race condition in idle monitor
    
    In _xsync_alarm_set(), the positive and negative transition intervals
    are set to the same value. However, the SYNC extension defines the
    positive transition as set when the counter goes from strictly below the
    threshold to greater than or equal to the threshold and similarly a
    negative transition is triggered when the counter goes form strictly
    greater than the threshold to less than or equal to the threshold.
    
    Thus in the current set up there's a chance that the positive transition
    can trigger, marking the session as idle, and some user input occur on
    the same click so the IDLETIME count will hit the threshold but not go
    above so the negative transition will not trigger. Thus the session will
    not be marked as active.
    
    The negative transition threshold should be set to 1ms less than the
    positive transition to ensure that it always fires.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=627903

 gnome-session/gs-idle-monitor.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/gnome-session/gs-idle-monitor.c b/gnome-session/gs-idle-monitor.c
index cd38dcb..d25144f 100644
--- a/gnome-session/gs-idle-monitor.c
+++ b/gnome-session/gs-idle-monitor.c
@@ -463,6 +463,7 @@ _xsync_alarm_set (GSIdleMonitor      *monitor,
                 watch->xalarm_positive = XSyncCreateAlarm (monitor->priv->display, flags, &attr);
         }
 
+        attr.trigger.wait_value = _int64_to_xsyncvalue (_xsyncvalue_to_int64 (watch->interval) - 1);
         attr.trigger.test_type = XSyncNegativeTransition;
         if (watch->xalarm_negative != None) {
                 g_debug ("GSIdleMonitor: updating alarm for negative transition wait=%lld",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]