summaryrefslogtreecommitdiff
path: root/db/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'db/client.h')
-rw-r--r--db/client.h28
1 files changed, 13 insertions, 15 deletions
diff --git a/db/client.h b/db/client.h
index 4e8589e..a8e3138 100644
--- a/db/client.h
+++ b/db/client.h
@@ -38,12 +38,13 @@ namespace mongo {
class CurOp;
class Command;
class Client;
- class MessagingPort;
+ class AbstractMessagingPort;
extern boost::thread_specific_ptr<Client> currentClient;
typedef long long ConnectionId;
+ /** the database's concept of an outside "client" */
class Client : boost::noncopyable {
public:
class Context;
@@ -52,14 +53,14 @@ namespace mongo {
static set<Client*> clients; // always be in clientsMutex when manipulating this
static int recommendedYieldMicros( int * writers = 0 , int * readers = 0 );
static int getActiveClientCount( int& writers , int& readers );
-
static Client *syncThread;
-
/* each thread which does db operations has a Client object in TLS.
call this when your thread starts.
*/
- static Client& initThread(const char *desc, MessagingPort *mp = 0);
+ static Client& initThread(const char *desc, AbstractMessagingPort *mp = 0);
+
+ ~Client();
/*
this has to be called as the client goes away, but before thread termination
@@ -67,17 +68,16 @@ namespace mongo {
*/
bool shutdown();
-
- ~Client();
-
+ /** set so isSyncThread() works */
void iAmSyncThread() {
wassert( syncThread == 0 );
syncThread = this;
}
- bool isSyncThread() const { return this == syncThread; } // true if this client is the replication secondary pull thread
-
+ /** @return true if this client is the replication secondary pull thread. not used much, is used in create index sync code. */
+ bool isSyncThread() const { return this == syncThread; }
string clientAddress(bool includePort=false) const;
+ const AuthenticationInfo * getAuthenticationInfo() const { return &_ai; }
AuthenticationInfo * getAuthenticationInfo() { return &_ai; }
bool isAdmin() { return _ai.isAuthorized( "admin" ); }
CurOp* curop() const { return _curOp; }
@@ -96,13 +96,12 @@ namespace mongo {
void gotHandshake( const BSONObj& o );
BSONObj getRemoteID() const { return _remoteId; }
BSONObj getHandshake() const { return _handshake; }
-
- MessagingPort * port() const { return _mp; }
-
+ AbstractMessagingPort * port() const { return _mp; }
ConnectionId getConnectionId() const { return _connectionId; }
private:
ConnectionId _connectionId; // > 0 for things "conn", 0 otherwise
+ string _threadId; // "" on non support systems
CurOp * _curOp;
Context * _context;
bool _shutdown;
@@ -112,9 +111,9 @@ namespace mongo {
ReplTime _lastOp;
BSONObj _handshake;
BSONObj _remoteId;
- MessagingPort * const _mp;
+ AbstractMessagingPort * const _mp;
- Client(const char *desc, MessagingPort *p = 0);
+ Client(const char *desc, AbstractMessagingPort *p = 0);
friend class CurOp;
@@ -128,7 +127,6 @@ namespace mongo {
~GodScope();
};
-
/* Set database we want to use, then, restores when we finish (are out of scope)
Note this is also helpful if an exception happens as the state if fixed up.
*/