Skip to content

Commit 545d8d8

Browse files
committed
SERVER-6018 Replace AtomicUInt with AtomicUInt32 in connpool
1 parent 41d8623 commit 545d8d8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/mongo/client/connpool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,6 @@ namespace mongo {
515515
pool.clear();
516516
}
517517

518-
AtomicUInt AScopedConnection::_numConnections;
518+
AtomicInt32 AScopedConnection::_numConnections;
519519

520520
} // namespace mongo

src/mongo/client/connpool.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "mongo/client/dbclientinterface.h"
3535
#include "mongo/client/export_macros.h"
36+
#include "mongo/platform/atomic_word.h"
3637
#include "mongo/platform/cstdint.h"
3738
#include "mongo/util/background.h"
3839

@@ -268,8 +269,8 @@ namespace mongo {
268269

269270
class MONGO_CLIENT_API AScopedConnection : boost::noncopyable {
270271
public:
271-
AScopedConnection() { _numConnections++; }
272-
virtual ~AScopedConnection() { _numConnections--; }
272+
AScopedConnection() { _numConnections.fetchAndAdd(1); }
273+
virtual ~AScopedConnection() { _numConnections.fetchAndAdd(-1); }
273274

274275
virtual DBClientBase* get() = 0;
275276
virtual void done() = 0;
@@ -283,10 +284,10 @@ namespace mongo {
283284
/**
284285
* @return total number of current instances of AScopedConnection
285286
*/
286-
static int getNumConnections() { return _numConnections; }
287+
static int getNumConnections() { return _numConnections.load(); }
287288

288289
private:
289-
static AtomicUInt _numConnections;
290+
static AtomicInt32 _numConnections;
290291
};
291292

292293
/** Use to get a connection from the pool. On exceptions things

0 commit comments

Comments
 (0)