]> granicus.if.org Git - curl/commitdiff
signal handling to cleanup on SIGINT and SIGTERM, followup
authorYang Tse <yangsita@gmail.com>
Wed, 9 Dec 2009 18:41:43 +0000 (18:41 +0000)
committerYang Tse <yangsita@gmail.com>
Wed, 9 Dec 2009 18:41:43 +0000 (18:41 +0000)
tests/server/sws.c
tests/server/util.c

index de16199d25bf1efceb25d01430ff1b05027a3976..ad851db89c77b60483ff18c432ba50a01524061f 100644 (file)
@@ -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");
index 6c50224065b8a9e4f07438e52ffaf95a47150336..7b00159ee0058fd218697f053b138395eb54446c 100644 (file)
@@ -203,7 +203,7 @@ int wait_ms(int timeout_ms)
     if(r != -1)
       break;
     error = SOCKERRNO;
-    if(error == EINVAL)
+    if(error && (error != EINTR))
       break;
     pending_ms = timeout_ms - (int)curlx_tvdiff(curlx_tvnow(), initial_tv);
     if(pending_ms <= 0)