summaryrefslogtreecommitdiff
path: root/src/mongo/client/distlock.cpp
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2012-12-19 15:23:57 -0500
committerGreg Studer <greg@10gen.com>2012-12-21 16:05:09 -0500
commit0950dfc242a2a04cf9fe1b680cca718d645939ad (patch)
treedfade474ef2a766770fdb692d33341d4569b729f /src/mongo/client/distlock.cpp
parent510dc00e63a9e33735f1d3afe21c4e5c5cd0077b (diff)
downloadmongo-0950dfc242a2a04cf9fe1b680cca718d645939ad.tar.gz
SERVER-7984 config upgrade from v3 to v4
Diffstat (limited to 'src/mongo/client/distlock.cpp')
-rw-r--r--src/mongo/client/distlock.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/mongo/client/distlock.cpp b/src/mongo/client/distlock.cpp
index aa5f8f07eae..3de63d8fdf2 100644
--- a/src/mongo/client/distlock.cpp
+++ b/src/mongo/client/distlock.cpp
@@ -1035,16 +1035,8 @@ namespace mongo {
<< " minutes timeout." << endl;
}
- ScopedDistributedLock::ScopedDistributedLock(const ConnectionString& conn,
- const string& name,
- const string& why,
- int lockTryIntervalMillis,
- unsigned long long lockTimeout,
- bool asProcess) :
- _lock(conn, name, lockTimeout, asProcess),
- _why(why),
- _lockTryIntervalMillis(lockTryIntervalMillis),
- _acquired(false)
+ ScopedDistributedLock::ScopedDistributedLock(const ConnectionString& conn, const string& name) :
+ _lock(conn, name), _why(""), _lockTryIntervalMillis(1000), _acquired(false)
{
}
@@ -1054,7 +1046,7 @@ namespace mongo {
}
}
- bool ScopedDistributedLock::tryAcquireOnce(string* errMsg) {
+ bool ScopedDistributedLock::tryAcquire(string* errMsg) {
bool acquired = false;
try {
acquired = _lock.lock_try(_why, false, &_other);
@@ -1074,7 +1066,7 @@ namespace mongo {
_lock.unlock(&_other);
}
- bool ScopedDistributedLock::tryAcquire(long long waitForMillis, string* errMsg) {
+ bool ScopedDistributedLock::acquire(long long waitForMillis, string* errMsg) {
string dummy;
if (!errMsg) errMsg = &dummy;
@@ -1085,7 +1077,7 @@ namespace mongo {
while (!_acquired && (waitForMillis <= 0 || timer.millis() < waitForMillis)) {
string acquireErrMsg;
- _acquired = tryAcquireOnce(&acquireErrMsg);
+ _acquired = tryAcquire(&acquireErrMsg);
if (_acquired) break;
@@ -1109,16 +1101,14 @@ namespace mongo {
if (_acquired) {
verify(!_other.isEmpty());
+ return true;
}
- else {
- *errMsg = str::stream() << "could not acquire distributed lock " << _lock._name
- << " for " << _why << " after " << timer.seconds()
- << "s, other lock may be held: " << _other << causedBy(errMsg);
- }
-
- return _acquired;
- }
+ *errMsg = str::stream() << "could not acquire distributed lock " << _lock._name << " for "
+ << _why << " after " << timer.seconds()
+ << "s, other lock may be held: " << _other << causedBy(errMsg);
+ return false;
+ }
}