aboutsummaryrefslogtreecommitdiff
path: root/tests/server/sws.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-12-09 18:41:43 +0000
committerYang Tse <yangsita@gmail.com>2009-12-09 18:41:43 +0000
commit0653fa107f6fb03555d49da86a1fbfc659873f5b (patch)
tree215598118d9fb3da2371791a8706203fa745f381 /tests/server/sws.c
parentebe5339003df6b4247f3637c4df5272a8dd69909 (diff)
signal handling to cleanup on SIGINT and SIGTERM, followup
Diffstat (limited to 'tests/server/sws.c')
-rw-r--r--tests/server/sws.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/server/sws.c b/tests/server/sws.c
index de16199d2..ad851db89 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -879,6 +879,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
}
}
+ if(got_exit_signal)
+ return -1;
+
dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */
if(!dump) {
error = ERRNO;
@@ -951,13 +954,27 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
if(cmdsize > 0 ) {
char command[32];
+ int quarters;
int num;
ptr=cmd;
do {
if(2 == sscanf(ptr, "%31s %d", command, &num)) {
if(!strcmp("wait", command)) {
logmsg("Told to sleep for %d seconds", num);
- sleep(num); /* wait this many seconds */
+ quarters = num * 4;
+ while(quarters > 0) {
+ quarters--;
+ res = wait_ms(250);
+ if(got_exit_signal)
+ quarters = 0;
+ if(res) {
+ /* should not happen */
+ error = SOCKERRNO;
+ logmsg("wait_ms() failed with error: (%d) %s",
+ error, strerror(error));
+ quarters = 0;
+ }
+ }
}
else
logmsg("Unknown command in reply command section");