[120901] trunk/base/src/pextlib1.0/curl.c

cal at macports.org cal at macports.org
Wed Jun 11 03:47:01 PDT 2014


Revision: 120901
          https://trac.macports.org/changeset/120901
Author:   cal at macports.org
Date:     2014-06-11 03:47:01 -0700 (Wed, 11 Jun 2014)
Log Message:
-----------
base: pextlib1.0/curl.c: Reduce excessive CPU usage while downloading

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/curl.c

Modified: trunk/base/src/pextlib1.0/curl.c
===================================================================
--- trunk/base/src/pextlib1.0/curl.c	2014-06-11 08:41:04 UTC (rev 120900)
+++ trunk/base/src/pextlib1.0/curl.c	2014-06-11 10:47:01 UTC (rev 120901)
@@ -511,15 +511,23 @@
 				break;
 			}
 
+			timeout.tv_sec = 1;
+			timeout.tv_usec = 0;
 			/* convert the timeout into a suitable format for select(2) and
 			 * limit the timeout to 500 msecs at most */
-			if (curl_timeout >= 0 && curl_timeout < 500) {
-				timeout.tv_usec = curl_timeout * 1000;
-			} else {
-				timeout.tv_usec = 500 * 1000;
+			if (curl_timeout > 0) {
+				timeout.tv_sec = curl_timeout / 1000;
+				if (timeout.tv_sec > 1) {
+					timeout.tv_sec = 1;
+				}
+
+				timeout.tv_usec = (curl_timeout % 1000) * 1000;
 			}
 
 			/* get the fd sets for select(2) */
+			FD_ZERO(&readfds);
+			FD_ZERO(&writefds);
+			FD_ZERO(&errorfds);
 			theCurlMCode = curl_multi_fdset(theMHandle, &readfds, &writefds, &errorfds, &nfds);
 			if (theCurlMCode != CURLM_OK) {
 				theResult = SetResultFromCurlMErrorCode(interp, theCurlMCode);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140611/c4bdbc07/attachment.html>


More information about the macports-changes mailing list