aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c6
-rw-r--r--tests/server/tftpd.c24
-rw-r--r--tests/server/util.c36
-rw-r--r--tests/server/util.h6
4 files changed, 67 insertions, 5 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index fc4123538..023fe270e 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -988,6 +988,8 @@ int main(int argc, char *argv[])
break;
}
+ set_advisor_read_lock(SERVERLOGS_LOCK);
+
#ifdef CURL_SWS_FORK_ENABLED
if(use_fork) {
/* The fork enabled version just forks off the child and don't care
@@ -1063,6 +1065,8 @@ int main(int argc, char *argv[])
logmsg("====> Client disconnect");
sclose(msgsock);
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+
if (req.testno == DOCNUMBER_QUIT)
break;
#ifdef CURL_SWS_FORK_ENABLED
@@ -1072,6 +1076,8 @@ int main(int argc, char *argv[])
sclose(sock);
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+
return 0;
}
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index a98791de6..bafe47cf6 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -415,6 +415,7 @@ int main(int argc, char **argv)
int flag;
int rc;
struct testcase test;
+ int result = 0;
while(argc>arg) {
if(!strcmp("--version", argv[arg])) {
@@ -518,20 +519,25 @@ int main(int argc, char **argv)
(struct sockaddr *)&from, &fromlen);
if (n < 0) {
logmsg("recvfrom:\n");
- return 3;
+ result = 3;
+ break;
}
+ set_advisor_read_lock(SERVERLOGS_LOCK);
+
from.sin_family = AF_INET;
peer = socket(AF_INET, SOCK_DGRAM, 0);
if (peer < 0) {
logmsg("socket:\n");
- return 2;
+ result = 2;
+ break;
}
if (connect(peer, (struct sockaddr *)&from, sizeof(from)) < 0) {
logmsg("connect: fail\n");
- return 1;
+ result = 1;
+ break;
}
maxtimeout = 5*TIMEOUT;
@@ -545,8 +551,14 @@ int main(int argc, char **argv)
free(test.buffer);
}
sclose(peer);
+
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+
} while(1);
- return 0;
+
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+
+ return result;
}
struct formats {
@@ -734,8 +746,10 @@ static void timer(int signum)
logmsg("alarm!");
timeout += rexmtval;
- if (timeout >= maxtimeout)
+ if(timeout >= maxtimeout) {
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
exit(1);
+ }
#ifdef HAVE_SIGSETJMP
siglongjmp(timeoutbuf, 1);
#endif
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));
+}
diff --git a/tests/server/util.h b/tests/server/util.h
index 4f07fcb05..9b9dd598b 100644
--- a/tests/server/util.h
+++ b/tests/server/util.h
@@ -27,6 +27,8 @@ void logmsg(const char *msg, ...);
#define TEST_DATA_PATH "%s/data/test%ld"
+#define SERVERLOGS_LOCK "log/serverlogs.lock"
+
/* global variable, where to find the 'data' dir */
extern const char *path;
@@ -53,4 +55,8 @@ int wait_ms(int timeout_ms);
int write_pidfile(const char *filename);
+void set_advisor_read_lock(const char *filename);
+
+void clear_advisor_read_lock(const char *filename);
+
#endif /* __SERVER_UTIL_H */