mirror of
https://github.com/MariaDB/server.git
synced 2026-05-08 08:04:29 +02:00
MDEV-24167 fixup: Avoid hangs in SRW_LOCK_DUMMY
In commit 1fdc161d8f we introduced
a mutex-and-condition-variable based fallback implementation
for platforms that lack a futex system call. That implementation
is prone to hangs.
Let us use separate condition variables for shared and exclusive requests.
This commit is contained in:
parent
a13fac9eee
commit
260161fc9f
2 changed files with 45 additions and 25 deletions
|
|
@ -35,7 +35,8 @@ class srw_lock_low final : private rw_lock
|
|||
#endif
|
||||
#ifdef SRW_LOCK_DUMMY
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
pthread_cond_t cond_shared;
|
||||
pthread_cond_t cond_exclusive;
|
||||
#endif
|
||||
/** @return pointer to the lock word */
|
||||
rw_lock *word() { return static_cast<rw_lock*>(this); }
|
||||
|
|
@ -46,11 +47,14 @@ class srw_lock_low final : private rw_lock
|
|||
void write_lock();
|
||||
/** Wait for signal
|
||||
@param l lock word from a failed acquisition */
|
||||
inline void wait(uint32_t l);
|
||||
inline void writer_wait(uint32_t l);
|
||||
/** Wait for signal
|
||||
@param l lock word from a failed acquisition */
|
||||
inline void readers_wait(uint32_t l);
|
||||
/** Send signal to one waiter */
|
||||
inline void wake_one();
|
||||
inline void writer_wake();
|
||||
/** Send signal to all waiters */
|
||||
inline void wake_all();
|
||||
inline void readers_wake();
|
||||
public:
|
||||
#ifdef SRW_LOCK_DUMMY
|
||||
void init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue