summaryrefslogtreecommitdiff
path: root/src/mongo/db/stats
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-04-07 16:49:06 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-04-20 14:06:16 -0400
commit84c4b7d15c6b98c7bb648bc60ade93b6af62b129 (patch)
tree6a0afa97d6f911c07089ccdf7bc29aa2deaed314 /src/mongo/db/stats
parent8e5b16fe0d64d587e0741dab7cabe64b0a818e51 (diff)
downloadmongo-84c4b7d15c6b98c7bb648bc60ade93b6af62b129.tar.gz
SERVER-17817 Make ServiceContext create and manage Client objects.
Also, deduplicate Client::* method implementations, guard the identity of the current CurOp of a Client with the Client's _mutex instead of the mutex guarding the list of all clients. Makes the currentClient object private to client.cpp, and all access to the thread-bound client is now done with haveClient() and cc() free functions in the mongo namespace. Removes the vesitgal Client::shutdown() methods.
Diffstat (limited to 'src/mongo/db/stats')
-rw-r--r--src/mongo/db/stats/lock_server_status_section.cpp39
-rw-r--r--src/mongo/db/stats/snapshots.cpp4
2 files changed, 16 insertions, 27 deletions
diff --git a/src/mongo/db/stats/lock_server_status_section.cpp b/src/mongo/db/stats/lock_server_status_section.cpp
index 1e81904b158..7b1350af9c0 100644
--- a/src/mongo/db/stats/lock_server_status_section.cpp
+++ b/src/mongo/db/stats/lock_server_status_section.cpp
@@ -55,35 +55,28 @@ namespace {
int numWaitingWrite = 0;
// This returns the blocked lock states
- {
- boost::lock_guard<boost::mutex> scopedLock(Client::clientsMutex);
-
- // Count all clients
- numTotal = Client::clients.size();
+ for (ServiceContext::LockedClientsCursor cursor(txn->getClient()->getServiceContext());
+ Client* client = cursor.next();) {
- ClientSet::const_iterator it = Client::clients.begin();
- for (; it != Client::clients.end(); it++) {
- Client* client = *it;
- invariant(client);
+ invariant(client);
+ ++numTotal;
+ boost::unique_lock<Client> uniqueLock(*client);
- boost::unique_lock<Client> uniqueLock(*client);
+ const OperationContext* opCtx = client->getOperationContext();
+ if (opCtx == NULL) continue;
- const OperationContext* opCtx = client->getOperationContext();
- if (opCtx == NULL) continue;
+ if (opCtx->lockState()->isWriteLocked()) {
+ numWriteLocked++;
- if (opCtx->lockState()->isWriteLocked()) {
- numWriteLocked++;
-
- if (opCtx->lockState()->getWaitingResource().isValid()) {
- numWaitingWrite++;
- }
+ if (opCtx->lockState()->getWaitingResource().isValid()) {
+ numWaitingWrite++;
}
- else if (opCtx->lockState()->isReadLocked()) {
- numReadLocked++;
+ }
+ else if (opCtx->lockState()->isReadLocked()) {
+ numReadLocked++;
- if (opCtx->lockState()->getWaitingResource().isValid()) {
- numWaitingRead++;
- }
+ if (opCtx->lockState()->getWaitingResource().isValid()) {
+ numWaitingRead++;
}
}
}
diff --git a/src/mongo/db/stats/snapshots.cpp b/src/mongo/db/stats/snapshots.cpp
index addf361bcb6..2e2d2f9398f 100644
--- a/src/mongo/db/stats/snapshots.cpp
+++ b/src/mongo/db/stats/snapshots.cpp
@@ -109,8 +109,6 @@ namespace mongo {
void SnapshotThread::run() {
Client::initThread("snapshot");
- Client& client = cc();
-
while ( ! inShutdown() ) {
try {
statsSnapshots.takeSnapshot();
@@ -121,8 +119,6 @@ namespace mongo {
sleepsecs(4);
}
-
- client.shutdown();
}
Snapshots statsSnapshots;