From ae09ad0ef5ffa2c24060d86f6769576ce6c66a8b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 4 Jun 2008 12:58:46 -0700 Subject: [PATCH] mon: use fcntl F_SETLK instead of flock --- src/mon/MonitorStore.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index 950e95809410b..8bc16804420e7 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -46,7 +46,13 @@ int MonitorStore::mount() lock_fd = ::open(t, O_CREAT|O_RDWR, 0600); if (lock_fd < 0) return -errno; - int r = ::flock(lock_fd, LOCK_EX|LOCK_NB); + struct flock l; + memset(&l, 0, sizeof(l)); + l.l_type = F_WRLCK; + l.l_whence = SEEK_SET; + l.l_start = 0; + l.l_len = 0; + int r = ::fcntl(lock_fd, F_SETLK, &l); if (r < 0) { derr(0) << "failed to lock " << t << ", is another cmon still running?" << dendl; return -errno; -- 2.39.5