]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: use fcntl F_SETLK instead of flock
authorSage Weil <sage@newdream.net>
Wed, 4 Jun 2008 19:58:46 +0000 (12:58 -0700)
committerSage Weil <sage@newdream.net>
Wed, 4 Jun 2008 19:58:46 +0000 (12:58 -0700)
src/mon/MonitorStore.cc

index 950e95809410b65504661131cfa12610af83d735..8bc16804420e74cf94632176dc300d1fdca066ab 100644 (file)
@@ -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;