summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2015-11-12 14:03:41 -0500
committerJason Rassi <rassi@10gen.com>2015-11-13 17:09:55 -0500
commit51e31f7dc5cff00d934a82b14422f61edeb2b994 (patch)
tree77f18aba0514485040b2fc599174b5470caf2c08 /src/mongo/db/client.h
parent26ad22c370276bf64a7c01f410006702d1736b92 (diff)
downloadmongo-51e31f7dc5cff00d934a82b14422f61edeb2b994.tar.gz
SERVER-21401 Ensure that Client outlives its associated messaging port
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 24cc847a430..5a500f4cf78 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -56,9 +56,15 @@ typedef long long ConnectionId;
/** the database's concept of an outside "client" */
class Client : public ClientBasic {
public:
- /** each thread which does db operations has a Client object in TLS.
- * call this when your thread starts.
- */
+ /**
+ * Creates a Client object and stores it in TLS for the current thread.
+ *
+ * An unowned pointer to a AbstractMessagingPort may optionally be provided. If 'mp' is
+ * non-null, then it will be used to augment the thread name, and for reporting purposes.
+ *
+ * If provided, 'mp' must outlive the newly-created Client object. Client::destroy() may be used
+ * to help enforce that the Client does not outlive 'mp'.
+ */
static void initThread(const char* desc, AbstractMessagingPort* mp = 0);
static void initThread(const char* desc,
ServiceContext* serviceContext,
@@ -75,6 +81,15 @@ public:
*/
static void initThreadIfNotAlready();
+ /**
+ * Destroys the Client object stored in TLS for the current thread. The current thread must have
+ * a Client.
+ *
+ * If destroy() is not called explicitly, then the Client stored in TLS will be destroyed upon
+ * exit of the current thread.
+ */
+ static void destroy();
+
std::string clientAddress(bool includePort = false) const;
const std::string& desc() const {
return _desc;