10 Jul 2012 22:22
patch - select.c / Curl_socket_check() interrupted
Maxime Larocque <maxmtl2002 <at> yahoo.ca>
2012-07-10 20:22:33 GMT
2012-07-10 20:22:33 GMT
Hello, 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(Continue reading)Funny to debug on a system on which OOM is a possible cause). The following patch corrects the problem (for curl 7.26 release, but look the same as 7.25): ======================================= diff -ur curl-7.26.0/lib/select.c curl-7.26.0b/lib/select.c --- curl-7.26.0/lib/select.c 2012-03-08 14:35:25.000000000 -0500 +++ curl-7.26.0b/lib/select.c 2012-07-10 16:02:13.915651510 -0400 <at> <at> -221,8 +221,10 <at> <at> break; if(timeout_ms > 0) { pending_ms = (int)(timeout_ms - elapsed_ms); - if(pending_ms <= 0)
Funny to debug on a system on which OOM is a possible cause).
The following patch corrects the problem (for curl 7.26 release, but
look the same as 7.25):
=======================================
diff -ur curl-7.26.0/lib/select.c curl-7.26.0b/lib/select.c
--- curl-7.26.0/lib/select.c 2012-03-08 14:35:25.000000000 -0500
+++ curl-7.26.0b/lib/select.c 2012-07-10 16:02:13.915651510 -0400
<at> <at> -221,8 +221,10 <at> <at>
break;
if(timeout_ms > 0) {
pending_ms = (int)(timeout_ms - elapsed_ms);
- if(pending_ms <= 0)
RSS Feed