diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp index 558a7e08ba..8c328be0f3 100644 --- a/src/common/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -1087,7 +1087,7 @@ namespace { #define PTHREAD_ERRNO(x) { int tmpState = (x); if (isPthreadError(tmpState, #x)) return tmpState; } #define LOG_PTHREAD_ERROR(x) isPthreadError((x), #x) #define PTHREAD_ERR_STATUS(x, v) { int tmpState = (x); if (tmpState) { error(v, #x, tmpState); return false; } } -#define PTHREAD_ERR_RAISE(x) { int tmpState = (x); if (tmpState) { system_call_failed(#x, tmpState); } } +#define PTHREAD_ERR_RAISE(x) { int tmpState = (x); if (tmpState) { system_call_failed::raise(#x, tmpState); } } #endif // USE_SHARED_FUTEX @@ -2025,7 +2025,7 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject #ifdef BUGGY_LINUX_MUTEX } #endif -#endif +#endif // HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL #ifdef USE_ROBUST_MUTEX #ifdef BUGGY_LINUX_MUTEX diff --git a/src/jrd/trace/TraceConfigStorage.cpp b/src/jrd/trace/TraceConfigStorage.cpp index 2abec11586..05fce3211a 100644 --- a/src/jrd/trace/TraceConfigStorage.cpp +++ b/src/jrd/trace/TraceConfigStorage.cpp @@ -144,6 +144,8 @@ void ConfigStorage::shutdown() if (!m_timer) return; + MutexLockGuard localGuard(m_localMutex, FB_FUNCTION); + m_timer->stop(); m_timer = NULL; @@ -290,6 +292,9 @@ void ConfigStorage::checkFile() void ConfigStorage::acquire() { + if (!m_sharedMemory) + (Arg::Gds(isc_random) << "Trace shared memory can not be accessed").raise(); + fb_assert(m_recursive >= 0); const ThreadId currTID = getThreadId(); @@ -309,6 +314,8 @@ void ConfigStorage::acquire() void ConfigStorage::release() { + fb_assert(m_sharedMemory); + fb_assert(m_recursive > 0); fb_assert(m_mutexTID == getThreadId()); diff --git a/src/jrd/trace/TraceConfigStorage.h b/src/jrd/trace/TraceConfigStorage.h index 9aa5fc6568..48fe4903da 100644 --- a/src/jrd/trace/TraceConfigStorage.h +++ b/src/jrd/trace/TraceConfigStorage.h @@ -67,6 +67,9 @@ public: void release(); void shutdown(); + + Firebird::Mutex m_localMutex; + private: void mutexBug(int osErrorCode, const char* text); bool initialize(Firebird::SharedMemoryBase*, bool); @@ -163,12 +166,11 @@ public: }; - -class StorageGuard +class StorageGuard : public Firebird::MutexLockGuard { public: explicit StorageGuard(ConfigStorage* storage) : - m_storage(storage) + Firebird::MutexLockGuard(storage->m_localMutex, FB_FUNCTION), m_storage(storage) { m_storage->acquire(); }