[PATCH 2/2] lock_reopen(): Properly handle EINTR in the unlock-on-error path
Thomas Jarosch
thomas.jarosch at intra2net.com
Sun Jul 19 06:06:47 EDT 2015
EINTR handling in lock_unlock() was introduced
with this commit:
commit b6f2c3ad6197c4ec1da5da6a79d79c2c93ed1a1c
Author: Larry Greenfield <leg at andrew.cmu.edu>
Date: Tue Nov 26 18:13:52 2002 +0000
look for EINTR on unlocks
---
lib/lock_fcntl.c | 12 ++----------
lib/lock_flock.c | 4 ++--
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/lib/lock_fcntl.c b/lib/lock_fcntl.c
index 883864e..fcfc1d7 100644
--- a/lib/lock_fcntl.c
+++ b/lib/lock_fcntl.c
@@ -91,11 +91,7 @@ EXPORTED int lock_reopen(int fd, const char *filename,
if (!r) r = stat(filename, &sbuffile);
if (r == -1) {
if (failaction) *failaction = "stating";
- fl.l_type= F_UNLCK;
- fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0;
- r = fcntl(fd, F_SETLKW, &fl);
+ r = lock_unlock(fd, filename);
return -1;
}
@@ -104,11 +100,7 @@ EXPORTED int lock_reopen(int fd, const char *filename,
newfd = open(filename, O_RDWR);
if (newfd == -1) {
if (failaction) *failaction = "opening";
- fl.l_type= F_UNLCK;
- fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0;
- r = fcntl(fd, F_SETLKW, &fl);
+ r = lock_unlock(fd, filename);
return -1;
}
dup2(newfd, fd);
diff --git a/lib/lock_flock.c b/lib/lock_flock.c
index eed0dd4..3a51139 100644
--- a/lib/lock_flock.c
+++ b/lib/lock_flock.c
@@ -88,7 +88,7 @@ EXPORTED int lock_reopen(int fd, const char *filename,
if (!r) r = stat(filename, &sbuffile);
if (r == -1) {
if (failaction) *failaction = "stating";
- flock(fd, LOCK_UN);
+ lock_unlock(fd, filename);
return -1;
}
@@ -97,7 +97,7 @@ EXPORTED int lock_reopen(int fd, const char *filename,
newfd = open(filename, O_RDWR);
if (newfd == -1) {
if (failaction) *failaction = "opening";
- flock(fd, LOCK_UN);
+ lock_unlock(fd, filename);
return -1;
}
dup2(newfd, fd);
--
1.9.3
More information about the Cyrus-devel
mailing list