Permalink
Browse files

fill lock owner in the other lock taken path

  • Loading branch information...
1 parent 3df26f8 commit 9c7814ffcdad9bae86d3661a123c4bb769dd1f19 Alberto Lerner committed Oct 26, 2010
Showing with 9 additions and 4 deletions.
  1. +9 −4 client/distlock.cpp
View
@@ -147,6 +147,11 @@ namespace mongo {
bool DistributedLock::lock_try( string why , BSONObj * other ){
+ // write to dummy if 'other' is null
+ BSONObj dummyOther;
+ if ( other == NULL )
+ other = &dummyOther;
+
ScopedDbConnection conn( _conn );
BSONObjBuilder queryBuilder;
@@ -179,6 +184,8 @@ namespace mongo {
if ( elapsed <= _takeoverMinutes ){
log(1) << "dist_lock lock failed because taken by: " << o << " elapsed minutes: " << elapsed << endl;
+ *other = o;
+ other->getOwned();
conn.done();
return false;
}
@@ -209,10 +216,8 @@ namespace mongo {
now = conn->findOne( _ns , _id );
if ( o["n"].numberInt() == 0 ){
- if ( other ){
- *other = now;
- other->getOwned();
- }
+ *other = now;
+ other->getOwned();
log() << "dist_lock error trying to aquire lock: " << lockDetails << " error: " << o << endl;
gotLock = false;
}

0 comments on commit 9c7814f

Please sign in to comment.