[sword-svn] r3876 - trunk/src/mgr
scribe at crosswire.org
scribe at crosswire.org
Sun Jul 31 08:23:25 EDT 2022
Author: scribe
Date: 2022-07-31 08:23:24 -0400 (Sun, 31 Jul 2022)
New Revision: 3876
Modified:
trunk/src/mgr/curlftpt.cpp
trunk/src/mgr/curlhttpt.cpp
Log:
Improve curlhttp transport to have parity with curlftp transport,
allowing request user cancel handled by progress callback)
Remove curl timeout, leaving only curl connect timeout, which was
the original intent of the timeout. If the user wants to keep
waiting, then we shouldn't stop the transfer. Have a means
for the user to cancel. The connect timeout is different: the
intent with this timeout is the cancel waiting for remote repos
which are down or blocking locations without waiting the curl
default 300 second connect timeout.
Modified: trunk/src/mgr/curlftpt.cpp
===================================================================
--- trunk/src/mgr/curlftpt.cpp 2022-05-29 22:39:23 UTC (rev 3875)
+++ trunk/src/mgr/curlftpt.cpp 2022-07-31 12:23:24 UTC (rev 3876)
@@ -156,7 +156,6 @@
curl_easy_setopt(session, CURLOPT_PROGRESSDATA, &pd);
curl_easy_setopt(session, CURLOPT_PROGRESSFUNCTION, my_fprogress);
-
curl_easy_setopt(session, CURLOPT_DEBUGFUNCTION, my_trace);
/* Set a pointer to our struct to pass to the callback */
curl_easy_setopt(session, CURLOPT_FILE, &ftpfile);
@@ -165,10 +164,8 @@
curl_easy_setopt(session, CURLOPT_VERBOSE, true);
#ifndef OLDCURL
curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT_MS, timeoutMillis);
- curl_easy_setopt(session, CURLOPT_TIMEOUT_MS, timeoutMillis);
#else
curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT, timeoutMillis/1000);
- curl_easy_setopt(session, CURLOPT_TIMEOUT, timeoutMillis/1000);
#endif
/* FTP connection settings */
Modified: trunk/src/mgr/curlhttpt.cpp
===================================================================
--- trunk/src/mgr/curlhttpt.cpp 2022-05-29 22:39:23 UTC (rev 3875)
+++ trunk/src/mgr/curlhttpt.cpp 2022-07-31 12:23:24 UTC (rev 3876)
@@ -61,13 +61,22 @@
return (int)FileMgr::write(out->fd, buffer, size * nmemb);
}
+ struct MyProgressData {
+ StatusReporter *sr;
+ bool *term;
+ };
static int my_httpfprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
if (clientp) {
- if (dltotal < 0) dltotal = 0;
- if (dlnow < 0) dlnow = 0;
- if (dlnow > dltotal) dlnow = dltotal;
- ((StatusReporter *)clientp)->update(dltotal, dlnow);
+ MyProgressData *pd = (MyProgressData *)clientp;
+SWLOGD("CURLFTPTransport report progress: totalSize: %ld; xfered: %ld\n", (long)dltotal, (long)dlnow);
+ if (pd->sr) {
+ if (dltotal < 0) dltotal = 0;
+ if (dlnow < 0) dlnow = 0;
+ if (dlnow > dltotal) dlnow = dltotal;
+ pd->sr->update(dltotal, dlnow);
+ }
+ if (*(pd->term)) return 1;
}
return 0;
}
@@ -119,6 +128,11 @@
CURLcode res;
if (session) {
+
+ struct MyProgressData pd;
+ pd.sr = statusReporter;
+ pd.term = &term;
+
curl_easy_setopt(session, CURLOPT_URL, sourceURL);
SWBuf credentials = u + ":" + p;
@@ -127,9 +141,10 @@
if (!passive)
curl_easy_setopt(session, CURLOPT_FTPPORT, "-");
curl_easy_setopt(session, CURLOPT_NOPROGRESS, 0);
- curl_easy_setopt(session, CURLOPT_FAILONERROR, 1);
- curl_easy_setopt(session, CURLOPT_PROGRESSDATA, statusReporter);
+ curl_easy_setopt(session, CURLOPT_PROGRESSDATA, &pd);
+ curl_easy_setopt(session, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(session, CURLOPT_PROGRESSFUNCTION, my_httpfprogress);
+
curl_easy_setopt(session, CURLOPT_DEBUGFUNCTION, myhttp_trace);
/* Set a pointer to our struct to pass to the callback */
curl_easy_setopt(session, CURLOPT_FILE, &ftpfile);
@@ -138,10 +153,8 @@
curl_easy_setopt(session, CURLOPT_VERBOSE, true);
#ifndef OLDCURL
curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT_MS, timeoutMillis);
- curl_easy_setopt(session, CURLOPT_TIMEOUT_MS, timeoutMillis);
#else
curl_easy_setopt(session, CURLOPT_CONNECTTIMEOUT, timeoutMillis/1000);
- curl_easy_setopt(session, CURLOPT_TIMEOUT, timeoutMillis/1000);
#endif
/* Disable checking host certificate */
More information about the sword-cvs
mailing list