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 <wjw@digiware.nl>
};
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;