summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-04-02 18:31:45 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-04-06 11:03:14 -0400
commit453c0b526ae5ed429caab2b6970d452c8d405a85 (patch)
tree21ca854cdbf18b5cb864081ba8bdbac31a3935ce /src/mongo/db
parente5557509152b2d2c8bf26af80f469ce09eddc9d1 (diff)
downloadmongo-453c0b526ae5ed429caab2b6970d452c8d405a85.tar.gz
SERVER-17817 Attach pointer to ServiceContext to ClientBasic.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/client.cpp7
-rw-r--r--src/mongo/db/client.h4
-rw-r--r--src/mongo/db/client_basic.cpp4
-rw-r--r--src/mongo/db/client_basic.h13
4 files changed, 21 insertions, 7 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 85617b55df5..a893bbeb756 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -54,6 +54,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
+#include "mongo/db/service_context.h"
#include "mongo/db/storage_options.h"
#include "mongo/s/chunk_version.h"
#include "mongo/s/d_state.h"
@@ -94,7 +95,7 @@ namespace mongo {
mongo::lastError.initThread();
// Create the client obj, attach to thread
- Client* client = new Client(fullDesc, mp);
+ Client* client = new Client(fullDesc, getGlobalServiceContext(), mp);
client->setAuthorizationSession(
new AuthorizationSession(
new AuthzSessionExternalStateMongod(getGlobalAuthorizationManager())));
@@ -106,8 +107,8 @@ namespace mongo {
clients.insert(client);
}
- Client::Client(const string& desc, AbstractMessagingPort *p)
- : ClientBasic(p),
+ Client::Client(const string& desc, ServiceContext* serviceContext, AbstractMessagingPort *p)
+ : ClientBasic(serviceContext, p),
_desc(desc),
_threadId(boost::this_thread::get_id()),
_connectionId(p ? p->connectionId() : 0),
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index b37b86bb4e9..bd0f3830fc0 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -124,7 +124,9 @@ namespace mongo {
private:
friend class CurOp;
- Client(const std::string& desc, AbstractMessagingPort *p = 0);
+ Client(const std::string& desc,
+ ServiceContext* serviceContext,
+ AbstractMessagingPort *p = 0);
// Description for the client (e.g. conn8)
diff --git a/src/mongo/db/client_basic.cpp b/src/mongo/db/client_basic.cpp
index 46bfcc44725..bbe1d729540 100644
--- a/src/mongo/db/client_basic.cpp
+++ b/src/mongo/db/client_basic.cpp
@@ -39,8 +39,8 @@ namespace mongo {
using boost::scoped_ptr;
- ClientBasic::ClientBasic(AbstractMessagingPort* messagingPort) : _messagingPort(messagingPort) {
- }
+ ClientBasic::ClientBasic(ServiceContext* serviceContext, AbstractMessagingPort* messagingPort) :
+ _serviceContext(serviceContext), _messagingPort(messagingPort) {}
ClientBasic::~ClientBasic() {}
AuthenticationSession* ClientBasic::getAuthenticationSession() {
diff --git a/src/mongo/db/client_basic.h b/src/mongo/db/client_basic.h
index 04a7a38f0f3..f2b1bd05a75 100644
--- a/src/mongo/db/client_basic.h
+++ b/src/mongo/db/client_basic.h
@@ -41,6 +41,7 @@ namespace mongo {
class AuthenticationInfo;
class AuthenticationSession;
class AuthorizationSession;
+ class ServiceContext;
/**
* this is the base class for Client and ClientInfo
@@ -73,16 +74,26 @@ namespace mongo {
verify( _messagingPort );
return _messagingPort->remote();
}
+
+ /**
+ * Returns the ServiceContext that owns this client session context.
+ */
+ ServiceContext* getServiceContext() const { return _serviceContext; }
+
+ /**
+ * Returns the AbstractMessagePort to which this client session is bound, if any.
+ */
AbstractMessagingPort * port() const { return _messagingPort; }
static ClientBasic* getCurrent();
protected:
- ClientBasic(AbstractMessagingPort* messagingPort);
+ ClientBasic(ServiceContext* serviceContext, AbstractMessagingPort* messagingPort);
private:
boost::scoped_ptr<AuthenticationSession> _authenticationSession;
boost::scoped_ptr<AuthorizationSession> _authorizationSession;
+ ServiceContext* const _serviceContext;
AbstractMessagingPort* const _messagingPort;
};
}