Hi, I obtained a POSIX file lock with the following code:
--- snip --- ... std::string x = "/tmp/ceph_mount/lock_file"; std::ofstream lock_file(x); lock_file.close(); // Lock automatically released by the OS when the process dies if (Sync::get_file_lock(x) == -1) { return false; } ... --- snip --- The code should create the file if it doesnt exist or just open it and close it if it does. Then the lock is taken. This is the code for get_file_lock: ---snip--- static int get_file_lock(const std::string& path, bool block = false, bool exclusive = true) { int fd, flags; if ((fd = open(path.c_str(), O_RDONLY)) == -1) throw LockingException(path); flags = (exclusive ? LOCK_EX : LOCK_SH); flags |= (block ? 0 : LOCK_NB); if (flock(fd, flags) == 0) return fd; close(fd); return -1; } ---snip--- I never release the lock but I expect the operating system (and ceph) to release it when the process terminates as this is normal POSIX behaviour. The observed behaviour is that the lock never gets released and after the process dies I can do the following: ---snip--- dev proc # cat locks 1: POSIX ADVISORY WRITE 4425 07:00:132 0 EOF 2: FLOCK ADVISORY WRITE 2906 fd:02:783456 0 EOF ---snip--- The lock taken by the process is the second one and the PID is correct (it's the PID of the process that took the lock). However the process doesn't exist any more, which I can verify with ps. Is this a bug in CEPH, am I doing something stupid, is it the expected behaviour? Regards, Dan -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html