summaryrefslogtreecommitdiff
path: root/tests/server/util.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-04-23 23:55:34 +0000
committerYang Tse <yangsita@gmail.com>2008-04-23 23:55:34 +0000
commit96edebf4d9ec656ec6ed83dca3bbc3947033c71d (patch)
tree85232db570c48e6f7258bc68f9966b5981cac3a5 /tests/server/util.c
parent3783b455c08d48cb8a487b16046ffdf71ba46dae (diff)
downloadcurl-96edebf4d9ec656ec6ed83dca3bbc3947033c71d.tar.gz
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
Diffstat (limited to 'tests/server/util.c')
-rw-r--r--tests/server/util.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/server/util.c b/tests/server/util.c
index 8a2fa8814..64684545e 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -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));
+}