Jelajahi Sumber

fix(core): stop download loop on slow connections (#5134)

A 3 second connect timeout is too short for slow or high-latency links:
DNS, TCP and TLS each need a round trip, so a 1 s RTT already fails.
Raise it to 10 seconds in both the bootstrap and core_dl.sh fetchers.

When a module download failed, fn_fetch_file called core_exit.sh, which
is itself fetched on demand. If core_exit.sh was not yet downloaded, its
fetch failed too and called core_exit.sh again, recursing forever
between GitHub and Bitbucket. fn_fetch_trap had the same recursion, so
CTRL+C could not break out. Exit directly when the file that failed is
core_exit.sh itself.

Fixes #4857
Daniel Gibbs 2 hari lalu
induk
melakukan
031da93d28
2 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 7 1
      lgsm/modules/core_dl.sh
  2. 1 1
      linuxgsm.sh

+ 7 - 1
lgsm/modules/core_dl.sh

@@ -372,6 +372,9 @@ fn_fetch_trap() {
 	echo -en "downloading ${local_filename}"
 	fn_print_removed_eol_nl
 	fn_script_log_info "Downloading ${local_filename}...REMOVED"
+	if [ "${local_filename}" == "core_exit.sh" ]; then
+		exit 130
+	fi
 	core_exit.sh
 }
 
@@ -486,7 +489,7 @@ fn_fetch_file() {
 			fi
 			# Trap will remove part downloaded files if canceled.
 			trap fn_fetch_trap INT
-			curlcmd=(curl --connect-timeout 3 --fail -L -o "${local_filedir}/${local_filename}" --retry 2 -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36")
+			curlcmd=(curl --connect-timeout 10 --fail -L -o "${local_filedir}/${local_filename}" --retry 2 -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36")
 			if [[ "${fileurl}" == https://* ]]; then
 				curlcmd+=(--proto-redir "=https")
 			fi
@@ -527,6 +530,9 @@ fn_fetch_file() {
 						fn_script_log_fail "Downloading ${local_filename}..."
 						fn_script_log_fail "${fileurl}"
 					fi
+					if [ "${local_filename}" == "core_exit.sh" ]; then
+						exit 1
+					fi
 					core_exit.sh
 				else
 					fn_print_error_eol_nl

+ 1 - 1
linuxgsm.sh

@@ -161,7 +161,7 @@ fn_bootstrap_fetch_file() {
 			fi
 			# Trap will remove part downloaded files if canceled.
 			trap fn_bootstrap_fetch_trap INT
-			curlcmd=(curl --connect-timeout 3 --fail -L -o "${local_filedir}/${local_filename}" --retry 2 -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36")
+			curlcmd=(curl --connect-timeout 10 --fail -L -o "${local_filedir}/${local_filename}" --retry 2 -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36")
 
 			# if is large file show progress, else be silent
 			local exitcode=""