• Mihai Moldovan's avatar
    nx-X11/programs/Xserver/hw/nxagent/Init.c: disable DPMS support within nxagent. · 76e7d26b
    Mihai Moldovan authored
    Keeping it enabled leads to nxagent consuming 100% of CPU resources
    after some time.
    
    Older code used three different timers for each DPMS mode (standby,
    suspend, off), with each timer checking that the elapsed idle time is
    strictly less than the DPMS mode timeout value.
    
    Newer code started merging DPMS and ScreenSaver timers into a single
    one, with checking DPMS modes and timeouts in a fall-through fashion.
    The code expects that, if a timeout is reached, the mode is set
    accordingly, so that the old timeout is disregarded next time.
    
    Since we stub out DPMSSetMode() in nxagent, this doesn't happen.
    
    In this case, the old DPMS timeout will be checked the next time around
    and we will be calculating DPMS_MODE_TIMEOUT - IDLE_TIME. If IDLE_TIME
    is bigger than DPMS_MODE_TIMEOUT, we run into problems with unsigned
    integers. What happens next will be *another* overflow once DoTimers()
    is executed and from that function SetTimers(), which will add the
    current timestamp to the timeout value. Later functions subtract the
    current timestamp again (which will be even higher since some time
    elapsed) and underflow the value again.
    
    It looks like this leads to consistent firing of the timer - something
    we do not want to have.
    
    For new, disable DPMS support in nxagent. We do not execute it on actual
    hardware that could change DPMS modes.
    
    At a later time, implementing a DPMS timeout/mode passthrough to the
    connected X server/display might be beneficial.
    
    Fixes: ArcticaProject/nx-libs#671
    76e7d26b
Init.c 13.4 KB