summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-05-12 16:57:28 -0400
committerEliot Horowitz <eliot@10gen.com>2011-05-12 18:31:59 -0400
commit78644abdfb4a7ca834e8bdeaed55cde51989de12 (patch)
treee8645f7b31f4ccdcc3bb1d9e744e943250d9fad3
parent2c201bf63b6e2377ce90298043e32f5902c34659 (diff)
downloadmongo-78644abdfb4a7ca834e8bdeaed55cde51989de12.tar.gz
fix deadlock
-rw-r--r--client/dbclient_rs.cpp7
-rw-r--r--client/dbclient_rs.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/client/dbclient_rs.cpp b/client/dbclient_rs.cpp
index 04099ee6bd5..3d010519ee2 100644
--- a/client/dbclient_rs.cpp
+++ b/client/dbclient_rs.cpp
@@ -292,7 +292,7 @@ namespace mongo {
newConn->connect( h , temp );
{
scoped_lock lk( _lock );
- if ( _find( toCheck ) >= 0 ) {
+ if ( _find_inlock( toCheck ) >= 0 ) {
// we need this check inside the lock so there isn't thread contention on adding to vector
continue;
}
@@ -397,12 +397,17 @@ namespace mongo {
int ReplicaSetMonitor::_find( const string& server ) const {
scoped_lock lk( _lock );
+ return _find_inlock( server );
+ }
+
+ int ReplicaSetMonitor::_find_inlock( const string& server ) const {
for ( unsigned i=0; i<_nodes.size(); i++ )
if ( _nodes[i].addr == server )
return i;
return -1;
}
+
int ReplicaSetMonitor::_find( const HostAndPort& server ) const {
scoped_lock lk( _lock );
for ( unsigned i=0; i<_nodes.size(); i++ )
diff --git a/client/dbclient_rs.h b/client/dbclient_rs.h
index 3d49fd28c29..e942d7b5b2a 100644
--- a/client/dbclient_rs.h
+++ b/client/dbclient_rs.h
@@ -124,6 +124,7 @@ namespace mongo {
bool _checkConnection( DBClientConnection * c , string& maybePrimary , bool verbose );
int _find( const string& server ) const ;
+ int _find_inlock( const string& server ) const ;
int _find( const HostAndPort& server ) const ;
mutable mongo::mutex _lock; // protects _nodes