summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-08-03 18:12:04 -0400
committerEliot Horowitz <eliot@10gen.com>2010-08-03 18:12:04 -0400
commitc1a0ce0228d75d62a10eeab6aa8aa0ee65b64958 (patch)
tree539096c537f360d5350f41e7221dab4f49a2ca8d /client
parent9078eba70f6e459c960a2c6b7c988a83947c2506 (diff)
downloadmongo-c1a0ce0228d75d62a10eeab6aa8aa0ee65b64958.tar.gz
check all shard connections at once so we don't get cascading failure SERVER-1560
Diffstat (limited to 'client')
-rw-r--r--client/connpool.h10
-rw-r--r--client/dbclientcursor.cpp10
-rw-r--r--client/dbclientcursor.h5
3 files changed, 12 insertions, 13 deletions
diff --git a/client/connpool.h b/client/connpool.h
index 94c56bd5854..00570c52d5b 100644
--- a/client/connpool.h
+++ b/client/connpool.h
@@ -96,10 +96,18 @@ namespace mongo {
extern DBConnectionPool pool;
+ class AScopedConnection : boost::noncopyable {
+ public:
+ virtual ~AScopedConnection(){}
+ virtual DBClientBase* get() = 0;
+ virtual void done() = 0;
+ virtual string getHost() const = 0;
+ };
+
/** Use to get a connection from the pool. On exceptions things
clean up nicely.
*/
- class ScopedDbConnection : boost::noncopyable {
+ class ScopedDbConnection : public AScopedConnection {
const string _host;
DBClientBase *_conn;
public:
diff --git a/client/dbclientcursor.cpp b/client/dbclientcursor.cpp
index 863424c77e0..07771bbf939 100644
--- a/client/dbclientcursor.cpp
+++ b/client/dbclientcursor.cpp
@@ -191,15 +191,7 @@ namespace mongo {
}
}
- void DBClientCursor::attach( ScopedDbConnection * conn ){
- assert( _scopedHost.size() == 0 );
- assert( connector == conn->get() );
- _scopedHost = conn->getHost();
- conn->done();
- connector = 0;
- }
-
- void DBClientCursor::attach( ShardConnection * conn ){
+ void DBClientCursor::attach( AScopedConnection * conn ){
assert( _scopedHost.size() == 0 );
assert( connector == conn->get() );
_scopedHost = conn->getHost();
diff --git a/client/dbclientcursor.h b/client/dbclientcursor.h
index 720c0adcff1..51cdc13caed 100644
--- a/client/dbclientcursor.h
+++ b/client/dbclientcursor.h
@@ -25,7 +25,7 @@
namespace mongo {
- class ShardConnection;
+ class AScopedConnection;
/** Queries return a cursor object */
class DBClientCursor : boost::noncopyable {
@@ -149,8 +149,7 @@ namespace mongo {
*/
void decouple() { _ownCursor = false; }
- void attach( ScopedDbConnection * conn );
- void attach( ShardConnection * conn );
+ void attach( AScopedConnection * conn );
private:
friend class DBClientBase;