diff options
author | Ben Caimano <ben.caimano@mongodb.com> | 2019-09-17 13:14:26 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-17 13:14:26 +0000 |
commit | 149c8f62af00f9dead5d4046368b8a2c3974cfbe (patch) | |
tree | 8e6abd648d927172d23fd1eb017ad6dc3ecc6a2a /src/mongo/platform | |
parent | 3897a749daab4f9e600af14205eba59775f9b278 (diff) | |
download | mongo-149c8f62af00f9dead5d4046368b8a2c3974cfbe.tar.gz |
SERVER-42595 Refactor failpoint in curop to fix jstest
Diffstat (limited to 'src/mongo/platform')
-rw-r--r-- | src/mongo/platform/mutex.cpp | 10 | ||||
-rw-r--r-- | src/mongo/platform/mutex.h | 8 |
2 files changed, 4 insertions, 14 deletions
diff --git a/src/mongo/platform/mutex.cpp b/src/mongo/platform/mutex.cpp index 47dd212c92c..49ececfd25e 100644 --- a/src/mongo/platform/mutex.cpp +++ b/src/mongo/platform/mutex.cpp @@ -43,17 +43,11 @@ void Mutex::lock() { if (gLockActions) { gLockActions->onContendedLock(_name); } - hasLock = _mutex.try_lock_for(_lockTimeout.toSystemDuration() - - kContendedLockTimeout.toSystemDuration()); - if (gLockActions && !hasLock) { - gLockActions->onFailedLock(); - } - uassert( - ErrorCodes::InternalError, "Unable to take latch, wait time exceeds set timeout", hasLock); + _mutex.lock(); } void Mutex::unlock() { if (gLockActions) { - gLockActions->onUnlock(); + gLockActions->onUnlock(_name); } _mutex.unlock(); } diff --git a/src/mongo/platform/mutex.h b/src/mongo/platform/mutex.h index 4ba2a7b7737..ded61a90783 100644 --- a/src/mongo/platform/mutex.h +++ b/src/mongo/platform/mutex.h @@ -42,20 +42,18 @@ class LockActions { public: virtual ~LockActions() = default; virtual void onContendedLock(const StringData& name) = 0; - virtual void onUnlock() = 0; - virtual void onFailedLock() = 0; + virtual void onUnlock(const StringData& name) = 0; }; class Mutex { public: static constexpr auto kAnonymousMutexStr = "AnonymousMutex"_sd; + static constexpr Milliseconds kContendedLockTimeout = Milliseconds(100); Mutex() : Mutex(kAnonymousMutexStr) {} // Note that StringData is a view type, thus the underlying string for _name must outlive any // given Mutex explicit Mutex(const StringData& name) : _name(name) {} - explicit Mutex(const StringData& name, Seconds lockTimeout) - : _name(name), _lockTimeout(lockTimeout) {} void lock(); void unlock(); @@ -68,8 +66,6 @@ public: private: const StringData _name; - const Seconds _lockTimeout = Seconds(60); - static constexpr Milliseconds kContendedLockTimeout = Milliseconds(100); stdx::timed_mutex _mutex; }; |