summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authorsamantharitter <samantha.ritter@10gen.com>2016-11-04 14:45:32 -0400
committersamantharitter <samantha.ritter@10gen.com>2016-11-05 21:26:59 -0400
commit0ac04999faae1d2fc0e10972aaf21082a2e48c8f (patch)
treed9b74efcf36c5381469cc622c3aea4c0f8166398 /src/mongo/db/client.h
parent2d1dd9e07a40f314853e29bffb56b45bf21df940 (diff)
downloadmongo-0ac04999faae1d2fc0e10972aaf21082a2e48c8f.tar.gz
SERVER-26674 transport::Session objects should be shared_ptr managed
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 8e313379b9c..50d4f5de541 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -56,10 +56,6 @@ class AbstractMessagingPort;
class Collection;
class OperationContext;
-namespace transport {
-class Session;
-} // namespace transport
-
typedef long long ConnectionId;
/**
@@ -73,13 +69,12 @@ public:
* An unowned pointer to a transport::Session may optionally be provided. If 'session'
* is non-null, then it will be used to augment the thread name, and for reporting purposes.
*
- * If provided, 'session' must outlive the newly-created Client object. Client::destroy() may
- * be used to help enforce that the Client does not outlive 'session.'
+ * If provided, session's ref count will be bumped by this Client.
*/
- static void initThread(const char* desc, transport::Session* session = nullptr);
+ static void initThread(const char* desc, transport::SessionHandle session = nullptr);
static void initThread(const char* desc,
ServiceContext* serviceContext,
- transport::Session* session);
+ transport::SessionHandle session);
static Client* getCurrent();
@@ -91,7 +86,7 @@ public:
}
bool hasRemote() const {
- return _session;
+ return (_session != nullptr);
}
HostAndPort getRemote() const {
@@ -109,10 +104,14 @@ public:
/**
* Returns the Session to which this client is bound, if any.
*/
- transport::Session* session() const {
+ const transport::SessionHandle& session() const& {
return _session;
}
+ transport::SessionHandle session() && {
+ return std::move(_session);
+ }
+
/**
* Inits a thread if that thread has not already been init'd, setting the thread name to
* "desc".
@@ -202,10 +201,12 @@ public:
private:
friend class ServiceContext;
- Client(std::string desc, ServiceContext* serviceContext, transport::Session* session = nullptr);
+ explicit Client(std::string desc,
+ ServiceContext* serviceContext,
+ transport::SessionHandle session);
ServiceContext* const _serviceContext;
- transport::Session* const _session;
+ const transport::SessionHandle _session;
// Description for the client (e.g. conn8)
const std::string _desc;