diff options
author | greg <greg@ubuntu.(none)> | 2011-03-02 15:17:53 -0500 |
---|---|---|
committer | greg <greg@ubuntu.(none)> | 2011-03-02 15:58:29 -0500 |
commit | 8bee4e23551482d31913638540177e0a75e2cb67 (patch) | |
tree | d3c1ff2f6b92ccafd2da05ab94166eb21b2fdfe3 /client | |
parent | 0550b00028c6a669cd3b8aeb1498744f7e4b4cdc (diff) | |
download | mongo-8bee4e23551482d31913638540177e0a75e2cb67.tar.gz |
fix distributed lock assignment
Diffstat (limited to 'client')
-rw-r--r-- | client/distlock.h | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/client/distlock.h b/client/distlock.h index d957fa3fef8..34a35d06a10 100644 --- a/client/distlock.h +++ b/client/distlock.h @@ -161,11 +161,31 @@ namespace mongo { dist_lock_try() : _lock(NULL), _got(false) {} - // Needed so we can handle lock exceptions in context of lock try. - dist_lock_try( const dist_lock_try& that) : _lock(that._lock), _got(that._got), _other(that._other) { + dist_lock_try( const dist_lock_try& that ) : _lock(that._lock), _got(that._got), _other(that._other) { + _other.getOwned(); + // Make sure the lock ownership passes to this object, // so we only unlock once. ((dist_lock_try&) that)._got = false; + ((dist_lock_try&) that)._lock = NULL; + } + + // Needed so we can handle lock exceptions in context of lock try. + dist_lock_try& operator=( const dist_lock_try& that ){ + + if( this == &that ) return *this; + + _lock = that._lock; + _got = that._got; + _other = that._other; + _other.getOwned(); + + // Make sure the lock ownership passes to this object, + // so we only unlock once. + ((dist_lock_try&) that)._got = false; + ((dist_lock_try&) that)._lock = NULL; + + return *this; } dist_lock_try( DistributedLock * lock , string why ) |