summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-05-16 13:15:42 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2016-05-16 13:15:42 +0000
commit5dfc67bf332c73ae1cb690974693721d3ad59307 (patch)
tree17016e47bf2322b4e1c427faacf5f1f5c333820b
parentbd5636c916fb13be2b3665059adedaad385c88e1 (diff)
downloadabuild-5dfc67bf332c73ae1cb690974693721d3ad59307.tar.bz2
abuild-5dfc67bf332c73ae1cb690974693721d3ad59307.tar.xz
abuild-fetch: retry to create lock on ESTALE
-rw-r--r--abuild-fetch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/abuild-fetch.c b/abuild-fetch.c
index aaac7b3..d723550 100644
--- a/abuild-fetch.c
+++ b/abuild-fetch.c
@@ -26,6 +26,7 @@ THE SOFTWARE.
#include <sys/wait.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
@@ -99,9 +100,16 @@ int fetch(char *url, const char *destdir)
err(1, lockfile);
if (fcntl(lockfd, F_SETLK, &fl) < 0) {
+ int i;
printf("Waiting for %s ...\n", lockfile);
- if (fcntl(lockfd, F_SETLKW, &fl) < 0)
- err(1, "fcntl(F_SETLKW)");
+ for (i=0; i<10; i++) {
+ int r = fcntl(lockfd, F_SETLKW, &fl);
+ if (r == 0)
+ break;
+ if (r == -1 && errno != ESTALE)
+ err(1, "fcntl(F_SETLKW)");
+ sleep(1);
+ }
}
if (access(outfile, F_OK) == 0)