summaryrefslogtreecommitdiff
path: root/src/mongo/transport/session.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/transport/session.h
parent2d1dd9e07a40f314853e29bffb56b45bf21df940 (diff)
downloadmongo-0ac04999faae1d2fc0e10972aaf21082a2e48c8f.tar.gz
SERVER-26674 transport::Session objects should be shared_ptr managed
Diffstat (limited to 'src/mongo/transport/session.h')
-rw-r--r--src/mongo/transport/session.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/mongo/transport/session.h b/src/mongo/transport/session.h
index 026a3445bb4..29e54333ceb 100644
--- a/src/mongo/transport/session.h
+++ b/src/mongo/transport/session.h
@@ -28,6 +28,8 @@
#pragma once
+#include <memory>
+
#include "mongo/base/disallow_copying.h"
#include "mongo/transport/message_compressor_manager.h"
#include "mongo/transport/session_id.h"
@@ -43,12 +45,16 @@ struct SSLPeerInfo;
namespace transport {
class TransportLayer;
+class Session;
+
+using SessionHandle = std::shared_ptr<Session>;
+using ConstSessionHandle = std::shared_ptr<const Session>;
/**
* This type contains data needed to associate Messages with connections
* (on the transport side) and Messages with Client objects (on the database side).
*/
-class Session {
+class Session : public std::enable_shared_from_this<Session> {
MONGO_DISALLOW_COPYING(Session);
public:
@@ -68,20 +74,14 @@ public:
static constexpr TagMask kKeepOpen = 1;
/**
- * Construct a new session.
- */
- Session(HostAndPort remote, HostAndPort local, TransportLayer* tl);
-
- /**
* Destroys a session, calling end() for this session in its TransportLayer.
*/
~Session();
/**
- * Move constructor and assignment operator.
+ * A factory for sessions.
*/
- Session(Session&& other);
- Session& operator=(Session&& other);
+ static SessionHandle create(HostAndPort remote, HostAndPort local, TransportLayer* tl);
/**
* Return the id for this session.
@@ -149,6 +149,11 @@ public:
}
private:
+ /**
+ * Construct a new session.
+ */
+ Session(HostAndPort remote, HostAndPort local, TransportLayer* tl);
+
Id _id;
HostAndPort _remote;