diff options
-rw-r--r-- | src/mongo/client/scoped_db_conn_test.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mongo/client/scoped_db_conn_test.cpp b/src/mongo/client/scoped_db_conn_test.cpp index d83335fb498..904f03af576 100644 --- a/src/mongo/client/scoped_db_conn_test.cpp +++ b/src/mongo/client/scoped_db_conn_test.cpp @@ -265,6 +265,7 @@ protected: uint64_t arg2, size_t newConnsToCreate) { vector<ScopedDbConnection*> newConnList; + for (size_t x = 0; x < newConnsToCreate; x++) { ScopedDbConnection* newConn = new ScopedDbConnection(TARGET_HOST); checkFunc(newConn->get()->getSockCreationMicroSec(), arg2); @@ -273,21 +274,32 @@ protected: const uint64_t oldCreationTime = curTimeMicros64(); + uint64_t validConnCount = 0; for (vector<ScopedDbConnection*>::iterator iter = newConnList.begin(); iter != newConnList.end(); ++iter) { + + if ((*iter)->get()->isStillConnected()) { + validConnCount++; + } + // Connection(s) could still go bad after this point and cause the test to fail. + (*iter)->done(); delete *iter; } newConnList.clear(); - // Check that connections created after the purge was put back to the pool. + uint64_t reusedConnCount = 0; + // Check that valid connections created after the purge were put back to the pool. for (size_t x = 0; x < newConnsToCreate; x++) { ScopedDbConnection* newConn = new ScopedDbConnection(TARGET_HOST); - ASSERT_LESS_THAN(newConn->get()->getSockCreationMicroSec(), oldCreationTime); + if (newConn->get()->getSockCreationMicroSec() < oldCreationTime) { + reusedConnCount++; + } newConnList.push_back(newConn); } + ASSERT_EQ(validConnCount, reusedConnCount); for (vector<ScopedDbConnection*>::iterator iter = newConnList.begin(); iter != newConnList.end(); |