Revert "Use os file locking to lock dbpath"
This reverts commit 56e81849a0.
This commit is contained in:
18
db/db.cpp
18
db/db.cpp
@@ -319,29 +319,13 @@ namespace mongo {
|
||||
|
||||
Timer startupSrandTimer;
|
||||
|
||||
void acquirePathLock() {
|
||||
#if !defined(_WIN32)
|
||||
string name = lockFileName();
|
||||
|
||||
if ( boost::filesystem::exists( name ) ) {
|
||||
int l = open( name.c_str(), O_RDONLY | O_EXLOCK | O_NONBLOCK );
|
||||
massert( "Could not acquire lock for dbpath: " + name, l > 0 );
|
||||
boost::filesystem::remove( name );
|
||||
close( l );
|
||||
}
|
||||
void segvhandler(int x);
|
||||
|
||||
lockFile = open( name.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_EXLOCK | O_TRUNC | O_NONBLOCK, S_IRWXU | S_IRWXG | S_IRWXO );
|
||||
massert( "Could not acquire lock for dbpath: " + name, lockFile > 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void _initAndListen(int listenPort, const char *appserverLoc = null) {
|
||||
stringstream ss;
|
||||
ss << "dbpath (" << dbpath << ") does not exist";
|
||||
massert( ss.str().c_str(), boost::filesystem::exists( dbpath ) );
|
||||
|
||||
acquirePathLock();
|
||||
|
||||
clearTmpFiles();
|
||||
clearTmpCollections();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user