summaryrefslogtreecommitdiff
path: root/client/connpool.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-09-11 16:10:48 -0400
committerEliot Horowitz <eliot@10gen.com>2009-09-11 16:10:48 -0400
commit4040d9799f1190f711313f6fa725ec9878226eec (patch)
tree83e32f1764474b194255cec8e4654d9f6d4cf46d /client/connpool.h
parentff495b5b73ee6eb46f8cd06600fd99b4566db00e (diff)
downloadmongo-4040d9799f1190f711313f6fa725ec9878226eec.tar.gz
add hooks for connection pool
Diffstat (limited to 'client/connpool.h')
-rw-r--r--client/connpool.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/client/connpool.h b/client/connpool.h
index 87235226ac6..661028774eb 100644
--- a/client/connpool.h
+++ b/client/connpool.h
@@ -26,6 +26,12 @@ namespace mongo {
struct PoolForHost {
std::stack<DBClientBase*> pool;
};
+
+ class DBConnectionHook {
+ public:
+ virtual ~DBConnectionHook(){}
+ virtual void onCreate( DBClientBase * conn ) = 0;
+ };
/** Database connection pool.
@@ -45,6 +51,8 @@ namespace mongo {
class DBConnectionPool {
boost::mutex poolMutex;
map<string,PoolForHost*> pools; // servername -> pool
+ list<DBConnectionHook*> _hooks;
+ void onCreate( DBClientBase * conn );
public:
void flush();
DBClientBase *get(const string& host);
@@ -52,6 +60,7 @@ namespace mongo {
boostlock L(poolMutex);
pools[host]->pool.push(c);
}
+ void addHook( DBConnectionHook * hook );
};
extern DBConnectionPool pool;
@@ -111,7 +120,7 @@ namespace mongo {
~ScopedDbConnection() {
if ( _conn ) {
/* see done() comments above for why we log this line */
- out() << "~ScopedDBConnection: _conn != null\n";
+ log() << "~ScopedDBConnection: _conn != null" << endl;
kill();
}
}