• Robert Haas's avatar
    Fix corner-case bug in WaitEventSetWaitBlock on Windows. · 3b790d25
    Robert Haas authored
    If we do not reset the FD_READ event, WaitForMultipleObjects won't
    return it again again unless we've meanwhile read from the socket,
    which is generally true but not guaranteed.  WaitEventSetWaitBlock
    itself may fail to return the event to the caller if the latch is
    also set, and even if we changed that, the caller isn't obliged to
    handle all returned events at once.  On non-Windows systems, the
    socket-read event is purely level-triggered, so this issue does
    not exist.  To fix, make Windows reset the event when needed.
    
    This bug was introduced by 98a64d0b,
    and causes hangs when trying to use the pldebugger extension.
    
    Patch by Amit Kapial.  Reported and tested by Ashutosh Sharma, who
    also provided some analysis.  Further analysis by Michael Paquier.
    3b790d25
latch.h 6.63 KB