diff --git a/ircd/db_port.cc b/ircd/db_port.cc index 0dd0d43c4..a87eb19f2 100644 --- a/ircd/db_port.cc +++ b/ircd/db_port.cc @@ -24,7 +24,13 @@ static_assert rocksdb::port::Mutex::Mutex() noexcept { - memset(this, 0x0, sizeof(pthread_mutex_t)); + static_assert + ( + sizeof(mu_) >= sizeof(mu), + "Mutex is not fully initialized." + ); + + memset(&mu_, 0x0, sizeof(mu_)); if constexpr(RB_DEBUG_DB_PORT > 1) { @@ -125,7 +131,13 @@ static_assert rocksdb::port::RWMutex::RWMutex() noexcept { - memset(this, 0x0, sizeof(pthread_rwlock_t)); + static_assert + ( + sizeof(mu_) >= sizeof(mu), + "RWMutex is not fully initialized." + ); + + memset(&mu_, 0x0, sizeof(mu_)); if constexpr(RB_DEBUG_DB_PORT > 1) { @@ -252,7 +264,13 @@ static_assert rocksdb::port::CondVar::CondVar(Mutex *mu) noexcept { - memset(this, 0x0, sizeof(pthread_cond_t) + sizeof(Mutex *)); + static_assert + ( + sizeof(cv_) >= sizeof(cv), + "CondVar is not fully initialized." + ); + + memset(&cv_, 0x0, sizeof(cv_)); this->mu = mu; if constexpr(RB_DEBUG_DB_PORT > 1) diff --git a/ircd/db_port.h b/ircd/db_port.h index 73f7b445f..ddba9c0f3 100644 --- a/ircd/db_port.h +++ b/ircd/db_port.h @@ -41,7 +41,11 @@ class rocksdb::port::Mutex { friend class CondVar; - ctx::mutex mu; + union + { + ctx::mutex mu; + pthread_mutex_t mu_; + }; public: void Lock() noexcept; @@ -57,8 +61,13 @@ class rocksdb::port::Mutex class rocksdb::port::CondVar { + union + { + ctx::condition_variable cv; + pthread_cond_t cv_; + }; + Mutex *mu; - ctx::condition_variable cv; public: void Wait() noexcept; @@ -72,7 +81,11 @@ class rocksdb::port::CondVar class rocksdb::port::RWMutex { - ctx::shared_mutex mu; + union + { + ctx::shared_mutex mu; + pthread_rwlock_t mu_; + }; public: void ReadLock() noexcept;