summaryrefslogtreecommitdiff
path: root/src/mongo/platform
diff options
context:
space:
mode:
authorRahul Sundararaman <rahul.sundararaman@10gen.com>2019-07-31 11:29:16 -0400
committerRahul Sundararaman <rahul.sundararaman@10gen.com>2019-07-31 12:07:08 -0400
commitda8f5d7786e0d12b0831d0d60b16fa9cc871350e (patch)
treef2002c9dad40cc35442ee9661baef3a9d117d76a /src/mongo/platform
parent587b784040cf64f4e62bcf07bc38b60def249759 (diff)
downloadmongo-da8f5d7786e0d12b0831d0d60b16fa9cc871350e.tar.gz
SERVER-42363 Add test for backtrace on $currentOp
Diffstat (limited to 'src/mongo/platform')
-rw-r--r--src/mongo/platform/mutex.cpp3
-rw-r--r--src/mongo/platform/mutex.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/mongo/platform/mutex.cpp b/src/mongo/platform/mutex.cpp
index b5661cf6f53..47dd212c92c 100644
--- a/src/mongo/platform/mutex.cpp
+++ b/src/mongo/platform/mutex.cpp
@@ -45,6 +45,9 @@ void Mutex::lock() {
}
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);
}
diff --git a/src/mongo/platform/mutex.h b/src/mongo/platform/mutex.h
index bb885d0cbe1..63fcb2ff892 100644
--- a/src/mongo/platform/mutex.h
+++ b/src/mongo/platform/mutex.h
@@ -41,12 +41,15 @@ public:
virtual ~LockActions() = default;
virtual void onContendedLock(const StringData& name) = 0;
virtual void onUnlock() = 0;
+ virtual void onFailedLock() = 0;
};
class Mutex {
public:
Mutex() : Mutex("AnonymousMutex"_sd) {}
explicit Mutex(const StringData& name) : _name(name) {}
+ explicit Mutex(const StringData& name, Seconds lockTimeout)
+ : _name(name), _lockTimeout(lockTimeout) {}
void lock();
void unlock();