Merge pull request #23647 from wjwithagen/wjw-fix-pidfile-err

common: be more informative if set PID-file fails

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2018-08-23 19:24:49 +08:00 committed by GitHub
commit cf085103a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;