1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-10 19:45:04 -05:00

signal handling to cleanup on SIGINT and SIGTERM, followup

This commit is contained in:
Yang Tse 2009-12-09 18:41:43 +00:00
parent ebe5339003
commit 0653fa107f
2 changed files with 19 additions and 2 deletions

View 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 */ dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */
if(!dump) { if(!dump) {
error = ERRNO; error = ERRNO;
@ -951,13 +954,27 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
if(cmdsize > 0 ) { if(cmdsize > 0 ) {
char command[32]; char command[32];
int quarters;
int num; int num;
ptr=cmd; ptr=cmd;
do { do {
if(2 == sscanf(ptr, "%31s %d", command, &num)) { if(2 == sscanf(ptr, "%31s %d", command, &num)) {
if(!strcmp("wait", command)) { if(!strcmp("wait", command)) {
logmsg("Told to sleep for %d seconds", num); 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 else
logmsg("Unknown command in reply command section"); logmsg("Unknown command in reply command section");

View File

@ -203,7 +203,7 @@ int wait_ms(int timeout_ms)
if(r != -1) if(r != -1)
break; break;
error = SOCKERRNO; error = SOCKERRNO;
if(error == EINVAL) if(error && (error != EINTR))
break; break;
pending_ms = timeout_ms - (int)curlx_tvdiff(curlx_tvnow(), initial_tv); pending_ms = timeout_ms - (int)curlx_tvdiff(curlx_tvnow(), initial_tv);
if(pending_ms <= 0) if(pending_ms <= 0)