summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-01-03 12:22:00 -0500
committerEliot Horowitz <eliot@10gen.com>2011-01-03 13:16:13 -0500
commitaca009ca806cdc716d934d64af2d1f41ed8b89f2 (patch)
tree95f3a98c54bb951b63e84792b18a8228fc06ab48 /util
parent310507046010c0bf447db25859bc142c1a4ee492 (diff)
downloadmongo-aca009ca806cdc716d934d64af2d1f41ed8b89f2.tar.gz
put connectionId in Client and in getLastError
Diffstat (limited to 'util')
-rw-r--r--util/goodies.h6
-rw-r--r--util/util.cpp24
2 files changed, 19 insertions, 11 deletions
diff --git a/util/goodies.h b/util/goodies.h
index 055aed4a587..9e1f7d2d206 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -26,7 +26,11 @@ namespace mongo {
/* @return a dump of the buffer as hex byte ascii output */
string hexdump(const char *data, unsigned len);
- void setThreadName(const char * name);
+ /**
+ * @return if this name has an increasing counter associated, return the value
+ * otherwise 0
+ */
+ unsigned setThreadName(const char * name);
string getThreadName();
template<class T>
diff --git a/util/util.cpp b/util/util.cpp
index c29f7234a34..63588dee7dd 100644
--- a/util/util.cpp
+++ b/util/util.cpp
@@ -40,16 +40,19 @@ namespace mongo {
boost::thread_specific_ptr<string> _threadName;
- void _setThreadName( const char * name ){
+ unsigned _setThreadName( const char * name ){
static unsigned N = 0;
+
if ( strcmp( name , "conn" ) == 0 ){
+ unsigned n = ++N;
stringstream ss;
- ss << name << ++N;
+ ss << name << n;
_threadName.reset( new string( ss.str() ) );
+ return n;
}
- else {
- _threadName.reset( new string(name) );
- }
+
+ _threadName.reset( new string(name) );
+ return 0;
}
#if defined(_WIN32)
@@ -82,21 +85,22 @@ namespace mongo {
}
}
- void setThreadName(const char *name)
+ unsigned setThreadName(const char *name)
{
- _setThreadName( name );
+ unsigned n = _setThreadName( name );
#if !defined(_DEBUG)
// naming might be expensive so don't do "conn*" over and over
if( string("conn") == name )
- return;
+ return n;
#endif
setWinThreadName(name);
+ return n;
}
#else
- void setThreadName(const char * name ) {
- _setThreadName( name );
+ unsigned setThreadName(const char * name ) {
+ return _setThreadName( name );
}
#endif