diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-01-03 12:22:00 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-01-03 13:16:13 -0500 |
commit | aca009ca806cdc716d934d64af2d1f41ed8b89f2 (patch) | |
tree | 95f3a98c54bb951b63e84792b18a8228fc06ab48 /util | |
parent | 310507046010c0bf447db25859bc142c1a4ee492 (diff) | |
download | mongo-aca009ca806cdc716d934d64af2d1f41ed8b89f2.tar.gz |
put connectionId in Client and in getLastError
Diffstat (limited to 'util')
-rw-r--r-- | util/goodies.h | 6 | ||||
-rw-r--r-- | util/util.cpp | 24 |
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 |