2010-05-17 00:32:06 +02:00
|
|
|
// vars.cpp
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright (C) 2008 10gen Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,b
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
#include "value.h"
|
2010-05-26 06:46:49 +02:00
|
|
|
#include "mutex.h"
|
2010-05-17 00:32:06 +02:00
|
|
|
|
2011-01-04 06:40:41 +01:00
|
|
|
namespace mongo {
|
2010-05-17 00:32:06 +02:00
|
|
|
|
2010-12-08 09:32:35 +01:00
|
|
|
mongo::mutex _atomicMutex("_atomicMutex");
|
2010-08-11 22:48:54 +02:00
|
|
|
|
|
|
|
// intentional leak. otherwise destructor orders can be problematic at termination.
|
|
|
|
MutexDebugger &mutexDebugger = *(new MutexDebugger());
|
2010-05-26 06:46:49 +02:00
|
|
|
|
2011-01-04 06:40:41 +01:00
|
|
|
MutexDebugger::MutexDebugger() :
|
|
|
|
x( *(new boost::mutex()) ), magic(0x12345678) {
|
|
|
|
// optional way to debug lock order
|
|
|
|
/*
|
|
|
|
a = "a_lock";
|
|
|
|
b = "b_lock";
|
|
|
|
*/
|
2010-06-02 23:15:31 +02:00
|
|
|
}
|
|
|
|
|
2011-01-04 06:40:41 +01:00
|
|
|
void MutexDebugger::programEnding() {
|
2010-07-30 16:45:15 +02:00
|
|
|
if( logLevel>=1 && followers.size() ) {
|
2010-05-28 17:32:40 +02:00
|
|
|
std::cout << followers.size() << " mutexes in program" << endl;
|
2011-01-04 06:40:41 +01:00
|
|
|
for( map< mid, set<mid> >::iterator i = followers.begin(); i != followers.end(); i++ ) {
|
2010-06-02 22:38:28 +02:00
|
|
|
cout << i->first;
|
2011-01-04 06:40:41 +01:00
|
|
|
if( maxNest[i->first] > 1 )
|
2010-06-02 22:43:05 +02:00
|
|
|
cout << " maxNest:" << maxNest[i->first];
|
2010-06-02 22:38:28 +02:00
|
|
|
cout << '\n';
|
2010-05-26 06:46:49 +02:00
|
|
|
for( set<mid>::iterator j = i->second.begin(); j != i->second.end(); j++ )
|
|
|
|
cout << " " << *j << '\n';
|
|
|
|
}
|
|
|
|
cout.flush();
|
|
|
|
}
|
|
|
|
}
|
2010-05-17 00:32:06 +02:00
|
|
|
|
|
|
|
}
|