Skip to content
  • Claudio Saavedra's avatar
    gmain: g_main_context_check() can skip updating polled FD sources · fa45688f
    Claudio Saavedra authored and Philip Withnall's avatar Philip Withnall committed
    If there is a file descriptor source that has a lower priority
    than the one for sources that are going to be dispatched,
    all subsequent file descriptor sources (internally sorted by
    file descriptor identifier) do not get an update in their GPollRec
    and later on wrong sources can be dispatched.
    
    Fix this by first finding the first GPollRec that matches the current
    GPollFD, instead of relying on it to be the current one. At
    the same time, document the assumptions about the ordering of the
    file descriptor records and array and make explicit in the documentation
    that the array needs to be passed to g_main_context_check() as it was
    received from g_main_context_query().
    
    Added a new test that reproduces the bug by creating two file
    descriptor sources and an idle one. Since the first
    file descriptor created has a lower identifier and a low priority,
    the second one is not dispatched even when it has the same, higher,
    priority as the idle source. After fixing this bug, both
    higher priority sources are dispatched as expected.
    
    While this patch was written independently, a similar fix for this
    bug was first submitted by Eugene M in !562. Having a
    second fix that basically does the same is a reassurance that we
    are in the right here.
    
    Fixes #1592
    fa45688f