]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Let's spin until fcntl does not return EINTR due to a signal.
authormmj <none@none>
Thu, 13 Jan 2005 08:57:32 +0000 (19:57 +1100)
committermmj <none@none>
Thu, 13 Jan 2005 08:57:32 +0000 (19:57 +1100)
--- mylocking.c 16 Jun 2004 21:11:54 -0000      1.3
+++ mylocking.c 13 Jan 2005 08:56:24 -0000
@@ -34,7 +34,9 @@
        locktype.l_whence = SEEK_SET;
        locktype.l_start = 0;
        locktype.l_len = 0;
-       mylock = fcntl(fd, F_SETLKW, &locktype);
+       do {
+               mylock = fcntl(fd, F_SETLKW, &locktype);
+       while(mylock < 0 && errno == EINTR);

        return mylock;
 }
@@ -45,7 +47,9 @@
        struct flock locktype;

        locktype.l_type = F_UNLCK;
-       myunlock = fcntl(fd, F_SETLKW, &locktype);
+       do {
+               myunlock = fcntl(fd, F_SETLKW, &locktype);
+       while(myunlock < 0 && errno == EINTR)

        return myunlock;
 }

src/mylocking.c

index 82353df3f79626adabab4108e67b5c626c66b856..2d25f9c9c32744ae8d5ab2d4fd748211c7ac0a84 100644 (file)
@@ -34,7 +34,9 @@ int myexcllock(int fd)
        locktype.l_whence = SEEK_SET;
        locktype.l_start = 0;
        locktype.l_len = 0;
-       mylock = fcntl(fd, F_SETLKW, &locktype);
+       do {
+               mylock = fcntl(fd, F_SETLKW, &locktype);
+       while(mylock < 0 && errno == EINTR);
 
        return mylock;
 }
@@ -45,7 +47,9 @@ int myunlock(int fd)
        struct flock locktype;
 
        locktype.l_type = F_UNLCK;
-       myunlock = fcntl(fd, F_SETLKW, &locktype);
+       do {
+               myunlock = fcntl(fd, F_SETLKW, &locktype);
+       while(myunlock < 0 && errno == EINTR)
 
        return myunlock;
 }