summaryrefslogtreecommitdiff
path: root/lib/select.c
diff options
context:
space:
mode:
authorMaxime Larocque <maxmtl2002@yahoo.ca>2012-08-07 23:24:13 +0200
committerDaniel Stenberg <daniel@haxx.se>2012-08-07 23:24:13 +0200
commitb61e8b81f50385e9fa332990ffef53c0893b6cd1 (patch)
tree6e7343de11ac7ebe9b86cde2ff1fbd58a1f88fcf /lib/select.c
parent77f72aa6c3bc5876ce1aee8f059ebf303cd1e08f (diff)
downloadcurl-b61e8b81f50385e9fa332990ffef53c0893b6cd1.tar.gz
Curl_socket_check: fix return code for timeout
We found a problem with ftp transfer using libcurl (7.23 and 7.25) inside an application which is receiving unix signals (SIGUSR1, SIGUSR2...) almost continuously. (Linux 2.4, PowerPC, HAVE_POLL_FINE defined). Curl_socket_check() uses poll() to wait for the socket, and retries it when a signal is received (EINTR). However, if a signal is received and it also happens that the timeout has been reached, Curl_socket_check() returns -1 instead of 0 (indicating an error instead of a timeout). In our case, the result is an aborted connection even before the ftp banner is received from the server, and a return value of CURLE_OUT_OF_MEMORY from curl_easy_perform() (Curl_pp_multi_statemach(), in pingpong.c, actually returns OOM if Curl_socket_check() fails :-) Funny to debug on a system on which OOM is a possible cause). Bug: http://curl.haxx.se/mail/lib-2012-07/0122.html
Diffstat (limited to 'lib/select.c')
-rw-r--r--lib/select.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/select.c b/lib/select.c
index 40673ec9e..4196211c0 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -221,8 +221,10 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
break;
if(timeout_ms > 0) {
pending_ms = (int)(timeout_ms - elapsed_ms);
- if(pending_ms <= 0)
+ if(pending_ms <= 0) {
+ r = 0; /* Simulate a "call timed out" case */
break;
+ }
}
} while(r == -1);