abuild-fetch: try harder to yield

Try a bit harder to let other process aquire lock.

This will hopefully reduce flakiness of testsuite when builder is under
load.
This commit is contained in:
Natanael Copa 2023-04-18 10:42:53 +02:00
parent 6ef57910ab
commit 40ecb4b07c
1 changed files with 4 additions and 1 deletions

View File

@ -34,6 +34,7 @@ THE SOFTWARE.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
static char *program;
@ -181,7 +182,9 @@ fetch_done:
release_lock(lockfd);
// give other processes the chance to acquire the lock if they have the file open
sleep(0);
// sleep for a millisecond
const struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000};
nanosleep(&ts, NULL);
if (status == 0 || try_lock(lockfd))
unlink(lockfile);