From: Willem Jan Withagen Date: Mon, 20 Aug 2018 10:31:10 +0000 (+0200) Subject: common: be more informative if set PID-file fails X-Git-Tag: v14.0.1~516^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F23647%2Fhead;p=ceph.git common: be more informative if set PID-file fails The errors returned by fcntl(...F_SETLK...) can be: - -1 for any odd error - EAGAIN if locking does not work because the file is already locked. Differentiate in these to be more informative on what is going on. Signed-off-by: Willem Jan Withagen --- diff --git a/src/global/pidfile.cc b/src/global/pidfile.cc index de242d779b36..2de2f54b95a0 100644 --- a/src/global/pidfile.cc +++ b/src/global/pidfile.cc @@ -171,8 +171,14 @@ int pidfh::open(const ConfigProxy& 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;