Permalink
Browse files

make sure all threads that use a lock have a Client

  • Loading branch information...
1 parent 8e3bf0f commit ce7b2867452f9158ba548c370e95c6f3d348914d @erh erh committed Feb 10, 2010
Showing with 15 additions and 12 deletions.
  1. +11 −12 db/client.cpp
  2. +1 −0 db/db.cpp
  3. +3 −0 db/instance.cpp
View
@@ -56,7 +56,8 @@ namespace mongo {
bool Client::shutdown(){
_shutdown = true;
-
+ if ( inShutdown() )
+ return false;
{
boostlock bl(clientsMutex);
clients.erase(this);
@@ -154,23 +155,21 @@ namespace mongo {
return "no client";
return c->toString();
}
-
+
void curopWaitingForLock(){
Client * c = currentClient.get();
- if ( c ){
- CurOp * co = c->curop();
- if ( co ){
- co->waitingForLock();
- }
+ assert( c );
+ CurOp * co = c->curop();
+ if ( co ){
+ co->waitingForLock();
}
}
void curopGotLock(){
Client * c = currentClient.get();
- if ( c ){
- CurOp * co = c->curop();
- if ( co ){
- co->gotLock();
- }
+ assert(c);
+ CurOp * co = c->curop();
+ if ( co ){
+ co->gotLock();
}
}
View
@@ -1061,6 +1061,7 @@ namespace mongo {
int x;
sigwait( &asyncSignals, &x );
log() << "got kill or ctrl c signal " << x << " (" << strsignal( x ) << "), will terminate after current cmd ends" << endl;
+ Client::initThread( "interruptThread" );
exitCleanly();
}
View
@@ -624,6 +624,7 @@ namespace mongo {
/* not using log() herein in case we are already locked */
void dbexit( ExitCode rc, const char *why) {
+ Client * c = currentClient.get();
{
boostlock lk( exitMutex );
if ( numExitCalls++ > 0 ) {
@@ -634,6 +635,7 @@ namespace mongo {
stringstream ss;
ss << "dbexit: " << why << "; exiting immediately" << endl;
tryToOutputFatal( ss.str() );
+ if ( c ) c->shutdown();
::exit( rc );
}
}
@@ -650,6 +652,7 @@ namespace mongo {
}
tryToOutputFatal( "dbexit: really exiting now\n" );
+ if ( c ) c->shutdown();
::exit(rc);
}

0 comments on commit ce7b286

Please sign in to comment.