improve synchronization between test harness runtests.pl script

and test harness servers to minimize risk of false test failures.

http://curl.haxx.se/mail/lib-2008-04/0392.html
This commit is contained in:
Yang Tse 2008-04-23 23:55:34 +00:00
parent 3783b455c0
commit 96edebf4d9
7 changed files with 132 additions and 7 deletions

View file

@ -234,3 +234,39 @@ int write_pidfile(const char *filename)
logmsg("Wrote pid %ld to %s", pid, filename);
return 1; /* success */
}
void set_advisor_read_lock(const char *filename)
{
FILE *lockfile;
int error;
int res;
do {
lockfile = fopen(filename, "wb");
} while((lockfile == NULL) && ((error = ERRNO) == EINTR));
if(lockfile == NULL) {
logmsg("Error creating lock file %s error: %d %s",
filename, error, strerror(error));
return;
}
do {
res = fclose(lockfile);
} while(res && ((error = ERRNO) == EINTR));
if(res)
logmsg("Error closing lock file %s error: %d %s",
filename, error, strerror(error));
}
void clear_advisor_read_lock(const char *filename)
{
int error;
int res;
do {
res = unlink(filename);
} while(res && ((error = ERRNO) == EINTR));
if(res)
logmsg("Error removing lock file %s error: %d %s",
filename, error, strerror(error));
}