Revision
71038
Author
raimue@macports.org
Date
2010-08-30 06:58:34 -0700 (Mon, 30 Aug 2010)

Log Message

pextlib1.0/curl.c: Apply timeouts and minimum transfer rates apply for fetch to
avoid problems with very slow or unresponsive mirrors.

Modified Paths

Diff

Modified: trunk/base/src/pextlib1.0/curl.c (71037 => 71038)


--- trunk/base/src/pextlib1.0/curl.c	2010-08-30 10:52:26 UTC (rev 71037)
+++ trunk/base/src/pextlib1.0/curl.c	2010-08-30 13:58:34 UTC (rev 71038)
@@ -272,6 +272,27 @@
 			break;
 		}
 
+		/* set timeout on connections */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_TIMEOUT, _CURL_CONNECTION_TIMEOUT);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
+
+		/* set minimum connection speed */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_LOW_SPEED_LIMIT, _CURL_MINIMUM_XFER_SPEED);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
+
+		/* set timeout interval for connections < min xfer speed */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_LOW_SPEED_TIME, _CURL_MINIMUM_XFER_TIMEOUT);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
+
 		/* skip the header data */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_HEADER, 0);
 		if (theCurlCode != CURLE_OK) {