]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/global/pidfile.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / global / pidfile.cc
index 6dd5a756957c3a906e639fa4b2a387afef65b8fd..76621e0f4965c28b5bf2a33533a9fcbdbfb96616 100644 (file)
@@ -64,7 +64,7 @@ struct pidfh {
   }
   int verify();
   int remove();
-  int open(const md_config_t *conf);
+  int open(const ConfigProxy& conf);
   int write();
 };
 
@@ -132,7 +132,7 @@ int pidfh::remove()
   return 0;
 }
 
-int pidfh::open(const md_config_t *conf)
+int pidfh::open(const ConfigProxy& conf)
 {
   int len = snprintf(pf_path, sizeof(pf_path),
                    "%s", conf->pid_file.c_str());
@@ -171,8 +171,14 @@ int pidfh::open(const md_config_t *conf)
   };
   int r = ::fcntl(pf_fd, F_SETLK, &l);
   if (r < 0) {
-    derr << __func__ << ": failed to lock pidfile "
-        << pf_path << " because another process locked it." << dendl;
+    if (errno == EAGAIN || errno == EACCES) {
+      derr << __func__ << ": failed to lock pidfile "
+          << pf_path << " because another process locked it" 
+          << "': " << cpp_strerror(errno) << dendl;
+    } else {
+      derr << __func__ << ": failed to lock pidfile "
+          << pf_path << "': " << cpp_strerror(errno) << dendl;
+    }
     ::close(pf_fd);
     reset();
     return -errno;
@@ -209,14 +215,14 @@ void pidfile_remove()
   pfh = nullptr;
 }
 
-int pidfile_write(const md_config_t *conf)
+int pidfile_write(const ConfigProxy& conf)
 {
   if (conf->pid_file.empty()) {
     dout(0) << __func__ << ": ignore empty --pid-file" << dendl;
     return 0;
   }
 
-  assert(pfh == nullptr);
+  ceph_assert(pfh == nullptr);
 
   pfh = new pidfh();
   if (atexit(pidfile_remove)) {