Revert "Use os file locking to lock dbpath"

This reverts commit 56e81849a0.
This commit is contained in:
Aaron
2009-03-10 10:14:37 -04:00
parent 56e81849a0
commit 3931f7efcb
5 changed files with 5 additions and 32 deletions

View File

@@ -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();