summaryrefslogtreecommitdiff
path: root/db/db.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-04-01 13:48:02 -0400
committerAaron <aaron@10gen.com>2009-04-01 13:48:02 -0400
commit99a96884938cd1eee623f3f7b9da8cacc73b4439 (patch)
tree6403a2d0a68126477aa5b1b8995744ff37d87aba /db/db.cpp
parent8ad34d618694f5bdb19b16847b1879087a97f3c2 (diff)
downloadmongo-99a96884938cd1eee623f3f7b9da8cacc73b4439.tar.gz
Explicitly release lock on shutdown
Diffstat (limited to 'db/db.cpp')
-rw-r--r--db/db.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 3c3356ea841..b22ee276518 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -52,6 +52,8 @@ namespace mongo {
extern int ctr;
extern int callDepth;
+ extern int lockFile;
+
void setupSignals();
void closeAllSockets();
void startReplication();
@@ -332,9 +334,9 @@ namespace mongo {
void acquirePathLock() {
#if !defined(_WIN32) and !defined(__sunos__)
string name = ( boost::filesystem::path( dbpath ) / "mongod.lock" ).native_file_string();
- int f = open( name.c_str(), O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO );
- massert( "Unable to create / open lock file for dbpath: " + name, f > 0 );
- massert( "Unable to acquire lock for dbpath: " + name, flock( f, LOCK_EX | LOCK_NB ) == 0 );
+ lockFile = open( name.c_str(), O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO );
+ massert( "Unable to create / open lock file for dbpath: " + name, lockFile > 0 );
+ massert( "Unable to acquire lock for dbpath: " + name, flock( lockFile, LOCK_EX | LOCK_NB ) == 0 );
#endif
}