• David Vasek's avatar
    heap: in heap_replace(), replace properly even an identical element · 1769fdef
    David Vasek authored and Libor Peltan's avatar Libor Peltan committed
    Current code as used by evsched_schedule() has led to a corrupted heap
    (with its elements out of order), resulting in unpredictable event scheduling
    behaviour, including events being processed out of order or already scheduled
    events being postponed, sometimes for several days, weeks, or maybe longer.
    
    Solving it by modifying the heap.c library a little -- the new code properly
    handles a situation when the original element and the element it's being replaced by
    are identical (that is, the same memory object), but already containing a modified
    value than what originally was in the heap. Instead of comparing the new element
    with the one it replaces, we now start comparing it with its parent.
    
    This commit fixes an old bug introduced in:
    925ad42d
    1769fdef