X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Fexim_lock.c;h=541e80f3f2a25bf4d6a2fdbcae5ef1f4a99124ea;hb=493e0e6648552c0dce6c5225c8438d2829f1ac11;hp=37d9744771217b245aaf386faf3d337524984c08;hpb=19050083522f210e8bb4f1a5ba03928ed0077a49;p=exim.git diff --git a/src/src/exim_lock.c b/src/src/exim_lock.c index 37d974477..541e80f3f 100644 --- a/src/src/exim_lock.c +++ b/src/src/exim_lock.c @@ -9,6 +9,8 @@ Options: -fcntl use fcntl() lock Default is -fcntl -lockfile. Argument: the name of the lock file + +Copyright (c) The Exim Maintainers 2016 */ #include "os.h" @@ -36,7 +38,7 @@ in sys/file.h. */ #endif -typedef int BOOL; +typedef unsigned BOOL; #define FALSE 0 #define TRUE 1 @@ -216,7 +218,7 @@ for (i = 1; i < argc; i++) else usage(); } -if (quiet) verbose = 0; +if (quiet) verbose = FALSE; /* Can't use flock() if the OS doesn't provide it */ @@ -322,7 +324,7 @@ for (j = 0; j < lock_retries; j++) if (use_lockfile) { - int rc; + int rc, rc2; if (verbose) printf("exim_lock: creating lock file\n"); hd = open(hitchname, O_WRONLY | O_CREAT | O_EXCL, 0440); if (hd < 0) @@ -334,11 +336,12 @@ for (j = 0; j < lock_retries; j++) /* Apply hitching post algorithm. */ - if ((rc = link(hitchname, lockname)) != 0) fstat(hd, &statbuf); + if ((rc = link(hitchname, lockname)) != 0) + rc2 = fstat(hd, &statbuf); (void)close(hd); unlink(hitchname); - if (rc != 0 && statbuf.st_nlink != 2) + if (rc != 0 && (rc2 != 0 || statbuf.st_nlink != 2)) { printf("exim_lock: failed to link hitching post to lock file\n"); hd = -1;