[pacman-dev] [PATCH v7 2/2] add command line options for libcurl's "low speed" timeout

Christian Hesse list at eworm.de
Mon Nov 14 08:32:46 UTC 2016


From: Christian Hesse <mail at eworm.de>

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 doc/pacman.8.txt    | 13 +++++++++++++
 src/pacman/conf.h   |  4 +++-
 src/pacman/pacman.c | 14 ++++++++++++++
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index 0fa727e..6a46735 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -266,6 +266,19 @@ Upgrade Options (apply to '-S' and '-U')[[UO]]
 *\--needed*::
 	Do not reinstall the targets that are already up-to-date.
 
+*\--lowspeedlimit* <speed>::
+    Sets the speed in bytes per second that a download should be below during
+    `LowSpeedTime` seconds to abort the transfer for being too slow. Setting
+    'speed' to 0 will disable the speed check. Defaults to 1 byte per second.
+    Note that this option will not affect external programs specified by
+    `XferCommand`.
+
+*\--lowspeedtime* <time>::
+    Sets the time in seconds that a download should be below the `LowSpeedLimit`
+    transfer speed to abort the transfer for being too slow. Setting 'time' to
+    0 will disable the speed check. Defaults to 10 seconds. Note that this
+    option will not affect external programs specified by `XferCommand`.
+
 
 Query Options (apply to '-Q')[[QO]]
 -----------------------------------
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 17e5f27..9b77238 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -207,7 +207,9 @@ enum {
 	OP_VERBOSE,
 	OP_DOWNLOADONLY,
 	OP_REFRESH,
-	OP_ASSUMEINSTALLED
+	OP_ASSUMEINSTALLED,
+	OP_LOWSPEEDLIMIT,
+	OP_LOWSPEEDTIME
 };
 
 /* clean method */
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index be52d1b..f6a5f33 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -194,6 +194,12 @@ static void usage(int op, const char * const myname)
 				addlist(_("      --ignore <pkg>   ignore a package upgrade (can be used more than once)\n"));
 				addlist(_("      --ignoregroup <grp>\n"
 				          "                       ignore a group upgrade (can be used more than once)\n"));
+#ifdef HAVE_LIBCURL
+				addlist(_("      --lowspeedlimit <speed>\n"
+				          "                       bytes per second that a download should be below\n"));
+				addlist(_("      --lowspeedtime <time>\n"
+				          "                       time in seconds that a download should be below lowspeedlimit\n"));
+#endif
 				/* pass through */
 			case PM_OP_REMOVE:
 				addlist(_("  -d, --nodeps         skip dependency version checks (-dd to skip all checks)\n"));
@@ -713,6 +719,12 @@ static int parsearg_upgrade(int opt)
 		case OP_IGNOREGROUP:
 			parsearg_util_addlist(&(config->ignoregrp));
 			break;
+		case OP_LOWSPEEDLIMIT:
+			config->lowspeedlimit = parse_positive_long(optarg);
+			break;
+		case OP_LOWSPEEDTIME:
+			config->lowspeedtime = parse_positive_long(optarg);
+			break;
 		default: return 1;
 	}
 	return 0;
@@ -928,6 +940,8 @@ static int parseargs(int argc, char *argv[])
 		{"logfile",    required_argument, 0, OP_LOGFILE},
 		{"ignoregroup", required_argument, 0, OP_IGNOREGROUP},
 		{"needed",     no_argument,       0, OP_NEEDED},
+		{"lowspeedlimit", required_argument, 0, OP_LOWSPEEDLIMIT},
+		{"lowspeedtime", required_argument, 0, OP_LOWSPEEDTIME},
 		{"asexplicit",     no_argument,   0, OP_ASEXPLICIT},
 		{"arch",       required_argument, 0, OP_ARCH},
 		{"print-format", required_argument, 0, OP_PRINTFORMAT},
-- 
2.10.2


More information about the pacman-dev mailing list