START_PROFILE(syscall_linux_setlease);
#ifdef HAVE_KERNEL_OPLOCKS_LINUX
START_PROFILE(syscall_linux_setlease);
#ifdef HAVE_KERNEL_OPLOCKS_LINUX
- /* first set the signal handler */
- if(linux_set_lease_sighandler(fsp->fh->fd) == -1) {
- return -1;
- }
-
result = linux_setlease(fsp->fh->fd, leasetype);
#else
errno = ENOSYS;
result = linux_setlease(fsp->fh->fd, leasetype);
#else
errno = ENOSYS;
+ /* First set the signal handler. */
+ if (linux_set_lease_sighandler(fd) == -1) {
+ return -1;
+ }
ret = fcntl(fd, F_SETLEASE, leasetype);
if (ret == -1 && errno == EACCES) {
set_effective_capability(LEASE_CAPABILITY);
ret = fcntl(fd, F_SETLEASE, leasetype);
if (ret == -1 && errno == EACCES) {
set_effective_capability(LEASE_CAPABILITY);
+ /*
+ * Bug 8974 - work around Linux kernel bug
+ * https://bugzilla.kernel.org/show_bug.cgi?id=43336.
+ * "fcntl(F_SETLEASE) resets signal number when
+ * called multiple times"
+ */
+ if (linux_set_lease_sighandler(fd) == -1) {
+ return -1;
+ }
ret = fcntl(fd, F_SETLEASE, leasetype);
}
ret = fcntl(fd, F_SETLEASE, leasetype);
}