• Marko Mäkelä's avatar
    MDEV-24142/MDEV-24167 fixup: Split ssux_lock and srw_lock · 43d3dad1
    Marko Mäkelä authored
    This conceptually reverts commit 1fdc161d
    and reintroduces an option for srw_lock to wrap a native implementation.
    
    The srw_lock and srw_lock_low differ from ssux_lock and ssux_lock_low
    in that Slim SUX locks support three modes (Shared, Update, eXclusive)
    while Slim RW locks support only two (Read, Write).
    
    On Microsoft Windows, the srw_lock will be implemented by SRWLOCK.
    On Linux and OpenBSD, it will be implemented by rw_lock and the
    futex system call, just like earlier.
    On other systems or if SRW_LOCK_DUMMY is defined on anything else
    than Microsoft Windows, rw_lock_t will be used.
    
    ssux_lock_low::read_lock(), ssux_lock_low::update_lock(): Correct
    the SRW_LOCK_DUMMY implementation to prevent hangs. The intention of
    commit 1fdc161d seems to have been
    do ... while loops, but the 'do' keyword was missing. This total
    breakage was missed in commit 260161fc
    which did reduce the probability of the hangs.
    
    ssux_lock_low::u_unlock(): In the SRW_LOCK_DUMMY implementation
    (based on a mutex and two condition variables), always invoke
    writer_wake() in order to ensure that a waiting update_lock()
    will be woken up.
    
    ssux_lock_low::writer_wait(), ssux_lock_low::readers_wait():
    In the SRW_LOCK_DUMMY implementation, keep waiting for the signal
    until the lock word has changed. The "while" had been changed to "if"
    in order to avoid hangs.
    43d3dad1
srw_lock.h 7.98 KB