summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-08-26 15:55:24 -0400
committerEliot Horowitz <eliot@10gen.com>2010-09-15 14:19:42 -0400
commit7a36dfe91027b49f5686aa957a662d78a82a609a (patch)
treeed272596947538add84a8582c4f42aa55aeb467d
parent955cb0426883b49f818e7e8ca0460917564321db (diff)
downloadmongo-7a36dfe91027b49f5686aa957a662d78a82a609a.tar.gz
fix nested CurOp cleaning SERVER-1610
-rw-r--r--db/client.cpp21
-rw-r--r--db/curop.h5
-rw-r--r--jstests/evalc.js13
3 files changed, 26 insertions, 13 deletions
diff --git a/db/client.cpp b/db/client.cpp
index f1d6bf6bfcd..63e46495b7b 100644
--- a/db/client.cpp
+++ b/db/client.cpp
@@ -52,15 +52,21 @@ namespace mongo {
}
Client::~Client() {
- delete _curOp;
_god = 0;
if ( _context )
error() << "Client::~Client _context should be NULL: " << _desc << endl;
- if ( !_shutdown )
+
+ if ( ! _shutdown ) {
error() << "Client::shutdown not called: " << _desc << endl;
+ }
+
+ scoped_lock bl(clientsMutex);
+ if ( ! _shutdown )
+ clients.erase(this);
+ delete _curOp;
}
-
+
void Client::_dropns( const string& ns ){
Top::global.collectionDropped( ns );
@@ -265,6 +271,15 @@ namespace mongo {
}
}
+ CurOp::~CurOp(){
+ if ( _wrapped ){
+ scoped_lock bl(Client::clientsMutex);
+ _client->_curOp = _wrapped;
+ }
+
+ _client = 0;
+ }
+
BSONObj CurOp::query( bool threadSafe ) {
if( querySize() == 1 ) {
return _tooBig;
diff --git a/db/curop.h b/db/curop.h
index fbeda9fc1e8..bf06a696f3d 100644
--- a/db/curop.h
+++ b/db/curop.h
@@ -222,10 +222,7 @@ namespace mongo {
memset(_queryBuf, 0, sizeof(_queryBuf));
}
- ~CurOp(){
- if ( _wrapped )
- _client->_curOp = _wrapped;
- }
+ ~CurOp();
BSONObj info() {
if( ! cc().getAuthenticationInfo()->isAuthorized("admin") ) {
diff --git a/jstests/evalc.js b/jstests/evalc.js
index 5569b8eeebd..75a319b865b 100644
--- a/jstests/evalc.js
+++ b/jstests/evalc.js
@@ -6,7 +6,6 @@ for( i = 0; i < 10; ++i ) {
}
// SERVER-1610
-if ( 0 ) {
function op() {
uri = db.runCommand( "whatsmyuri" ).you;
@@ -15,17 +14,19 @@ function op() {
for ( var i in p ) {
var o = p[ i ];
if ( o.client == uri ) {
+ print( "found it" );
return o.opid;
}
}
return -1;
}
-s = startParallelShell( "db.eval( 'while( 1 ) { db.jstests_evalc.count( {i:10} ); }' )" );
+s = startParallelShell( "print( 'starting forked:' + Date() ); for ( i=0; i<500000; i++ ){ db.currentOp(); } print( 'ending forked:' + Date() ); " )
-assert.soon( "op() != -1" );
-//db.killOp( op() );
+print( "starting eval: " + Date() )
+for ( i=0; i<50000; i++ ){
+ db.eval( "db.jstests_evalc.count( {i:10} );" );
+}
+print( "end eval: " + Date() )
s();
-
-} \ No newline at end of file