[sword-svn] r3783 - in trunk: include src/mgr utilities

scribe at crosswire.org scribe at crosswire.org
Thu Aug 27 14:27:58 EDT 2020


Author: scribe
Date: 2020-08-27 14:27:58 -0400 (Thu, 27 Aug 2020)
New Revision: 3783

Modified:
   trunk/include/installmgr.h
   trunk/include/remotetrans.h
   trunk/src/mgr/curlhttpt.cpp
   trunk/src/mgr/ftplibftpt.cpp
   trunk/src/mgr/installmgr.cpp
   trunk/src/mgr/remotetrans.cpp
   trunk/utilities/installmgr.cpp
Log:
InstallMgr: standardized and commented the internal return codes for transports
Better commented the terminate() method to suggest calling from a StatusReporter is threading is a concern
Added TimeoutMillis to InstallMgr.conf when calling installmgr -init


Modified: trunk/include/installmgr.h
===================================================================
--- trunk/include/installmgr.h	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/include/installmgr.h	2020-08-27 18:27:58 UTC (rev 3783)
@@ -271,7 +271,9 @@
 	void setUnverifiedPeerAllowed(bool allowed) { this->unverifiedPeerAllowed = allowed; }
 	bool isUnverifiedPeerAllowed() { return unverifiedPeerAllowed; }
 
-	/** call from another thread to terminate the installation process
+	/** Request nicely to terminate an ongoing transfer.
+	 * If threading is a concern, consider calling terminate() from your status reporters
+	 * as they are typically the link between the transfer thread and your UI.
 	 */
 	void terminate();
 

Modified: trunk/include/remotetrans.h
===================================================================
--- trunk/include/remotetrans.h	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/include/remotetrans.h	2020-08-27 18:27:58 UTC (rev 3783)
@@ -67,7 +67,7 @@
 	 * override this method in your real impl
 	 *
 	 * if destBuf then write to buffer instead of file
-	 * @return -1 simple error (resource not found); -2 more serious (connection error)
+	 * @return -1 operation error (e.g., resource not found); -2 connection error (e.g., connection timeout or login failure); -3 user requested termination
 	 */
 	virtual char getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf = 0);
 
@@ -75,7 +75,7 @@
 	 * override this method in your real impl
 	 *
 	 * if sourceBuf then read from buffer instead of file
-	 * @return -1 simple error (resource not found); -2 more serious (connection error)
+	 * @return -1 operation error (e.g., permission denied); -2 connection error (e.g., connection timeout or login failure); -3 user requested termination
 	 */
 	virtual char putURL(const char *destURL, const char *sourcePath, SWBuf *sourceBuf = 0);
 

Modified: trunk/src/mgr/curlhttpt.cpp
===================================================================
--- trunk/src/mgr/curlhttpt.cpp	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/src/mgr/curlhttpt.cpp	2020-08-27 18:27:58 UTC (rev 3783)
@@ -166,7 +166,7 @@
 
 		if(CURLE_OK != res) {
 			if (CURLE_FTP_ACCEPT_TIMEOUT == res || CURLE_OPERATION_TIMEDOUT == res) {
-				retVal = -3;
+				retVal = -2;
 			}
 			else {
 				retVal = -1;

Modified: trunk/src/mgr/ftplibftpt.cpp
===================================================================
--- trunk/src/mgr/ftplibftpt.cpp	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/src/mgr/ftplibftpt.cpp	2020-08-27 18:27:58 UTC (rev 3783)
@@ -123,7 +123,7 @@
 		}
 		else {
 			SWLog::getSystemLog()->logError("Failed to connect to %s\n", host.c_str());
-			retVal = -3;
+			retVal = -2;
 		}
 	}
 	return retVal;

Modified: trunk/src/mgr/installmgr.cpp
===================================================================
--- trunk/src/mgr/installmgr.cpp	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/src/mgr/installmgr.cpp	2020-08-27 18:27:58 UTC (rev 3783)
@@ -376,7 +376,7 @@
 			}
 		}
 		SWCATCH (...) {
-			retVal = -3;
+			retVal = -1;
 		}
 	}
 	SWTRY {
@@ -570,7 +570,7 @@
 		ZipCompress::unTarGZ(fd, root.c_str());
 		FileMgr::getSystemFileMgr()->close(fd);
 	}
-	else if (errorCode > -2) // -2 and greater errors are connection errors
+	else if (errorCode > -2)	// don't try the next attempt on connection error or user requested termination
 #endif
 	errorCode = remoteCopy(is, "mods.d", target.c_str(), true, ".conf"); //copy the whole directory
 

Modified: trunk/src/mgr/remotetrans.cpp
===================================================================
--- trunk/src/mgr/remotetrans.cpp	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/src/mgr/remotetrans.cpp	2020-08-27 18:27:58 UTC (rev 3783)
@@ -134,6 +134,9 @@
 }
 
 
+/** network copy recursively a remote directly
+ * @return error status 0: OK; -1: operation error, -2: connection error; -3: user requested termination
+ */
 int RemoteTransport::copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix) {
 	SWLog::getSystemLog()->logDebug("RemoteTransport::copyDirectory");
 	int retVal = 0;
@@ -196,9 +199,10 @@
 				removeTrailingSlash(url);
 				url += "/";
 				url += dirEntry.name;
-				if (getURL(buffer.c_str(), url.c_str())) {
+				retVal = getURL(buffer.c_str(), url.c_str());
+				if (retVal) {
 					SWLog::getSystemLog()->logWarning("copyDirectory: failed to get file %s\n", url.c_str());
-					return -2;
+					return retVal;
 				}
 				completedBytes += dirEntry.size;
 			}

Modified: trunk/utilities/installmgr.cpp
===================================================================
--- trunk/utilities/installmgr.cpp	2020-08-27 14:08:33 UTC (rev 3782)
+++ trunk/utilities/installmgr.cpp	2020-08-27 18:27:58 UTC (rev 3783)
@@ -209,6 +209,7 @@
 
 	SWConfig config(confPath.c_str());
 	config["General"]["PassiveFTP"] = "true";
+	config["General"]["TimeoutMillis"] = "10000";
 	config["General"]["UnverifiedPeerAllowed"] = (unverifiedPeerAllowed) ? "true" : "false";
 	if (enableRemote) {
 		config["Sources"]["FTPSource"] = is.getConfEnt();



More information about the sword-cvs mailing list