aboutsummaryrefslogtreecommitdiff
path: root/tests/server
diff options
context:
space:
mode:
Diffstat (limited to 'tests/server')
-rw-r--r--tests/server/sws.c23
-rw-r--r--tests/server/tftpd.c17
-rw-r--r--tests/server/util.c8
3 files changed, 42 insertions, 6 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index fab7ae59a..27434606d 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -74,6 +74,7 @@
static bool use_ipv6 = FALSE;
#endif
static const char *ipv_inuse = "IPv4";
+static int serverlogslocked = 0;
#define REQBUFSIZ 150000
#define REQBUFSIZ_TXT "149999"
@@ -1112,6 +1113,11 @@ int main(int argc, char *argv[])
goto sws_cleanup;
}
+ /*
+ ** As soon as this server writes its pid file the test harness will
+ ** attempt to connect to this server and initiate its verification.
+ */
+
wrotepidfile = write_pidfile(pidname);
if(!wrotepidfile)
goto sws_cleanup;
@@ -1128,7 +1134,14 @@ int main(int argc, char *argv[])
break;
}
+ /*
+ ** As soon as this server acepts a connection from the test harness it
+ ** must set the server logs advisor read lock to indicate that server
+ ** logs should not be read until this lock is removed by this server.
+ */
+
set_advisor_read_lock(SERVERLOGS_LOCK);
+ serverlogslocked = 1;
#ifdef CURL_SWS_FORK_ENABLED
if(use_fork) {
@@ -1215,7 +1228,10 @@ int main(int argc, char *argv[])
sclose(msgsock);
msgsock = CURL_SOCKET_BAD;
- clear_advisor_read_lock(SERVERLOGS_LOCK);
+ if(serverlogslocked) {
+ serverlogslocked = 0;
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+ }
if (req.testno == DOCNUMBER_QUIT)
break;
@@ -1238,7 +1254,10 @@ sws_cleanup:
if(wrotepidfile)
unlink(pidname);
- clear_advisor_read_lock(SERVERLOGS_LOCK);
+ if(serverlogslocked) {
+ serverlogslocked = 0;
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+ }
restore_signal_handlers();
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index e0c2d19e2..1f6418f59 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -103,6 +103,7 @@
static bool use_ipv6 = FALSE;
#endif
static const char *ipv_inuse = "IPv4";
+static int serverlogslocked = 0;
struct testcase {
char *buffer; /* holds the file data to send to the client */
@@ -546,6 +547,7 @@ int main(int argc, char **argv)
}
set_advisor_read_lock(SERVERLOGS_LOCK);
+ serverlogslocked = 1;
from.sin_family = AF_INET;
@@ -574,13 +576,19 @@ int main(int argc, char **argv)
}
sclose(peer);
- clear_advisor_read_lock(SERVERLOGS_LOCK);
+ if(serverlogslocked) {
+ serverlogslocked = 0;
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+ }
logmsg("end of one transfer");
}
- clear_advisor_read_lock(SERVERLOGS_LOCK);
+ if(serverlogslocked) {
+ serverlogslocked = 0;
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+ }
return result;
}
@@ -766,7 +774,10 @@ static void timer(int signum)
timeout += rexmtval;
if(timeout >= maxtimeout) {
- clear_advisor_read_lock(SERVERLOGS_LOCK);
+ if(serverlogslocked) {
+ serverlogslocked = 0;
+ clear_advisor_read_lock(SERVERLOGS_LOCK);
+ }
exit(1);
}
#ifdef HAVE_SIGSETJMP
diff --git a/tests/server/util.c b/tests/server/util.c
index 646e52bcf..6c5022406 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -260,6 +260,12 @@ void clear_advisor_read_lock(const char *filename)
int error = 0;
int res;
+ /*
+ ** Log all removal failures. Even those due to file not existing.
+ ** This allows to detect if unexpectedly the file has already been
+ ** removed by a process different than the one that should do this.
+ */
+
do {
res = unlink(filename);
} while(res && ((error = ERRNO) == EINTR));