From 59638ee05f22a4fc12caf0fd257c8115945e6340 Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Tue, 12 Aug 2008 21:43:15 +0000 Subject: squid: allow to tune the finish / abort transfer when aborted by client - settings --- packages/squid/squid.inc | 23 +++++++++++++++++++++++ packages/squid/squid_traffic.xml | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to 'packages') diff --git a/packages/squid/squid.inc b/packages/squid/squid.inc index 674f38cd..54834649 100644 --- a/packages/squid/squid.inc +++ b/packages/squid/squid.inc @@ -426,6 +426,25 @@ function squid_validate_traffic($post, $input_errors) { if (!is_numeric($value) || ($value < 0)) $input_errors[] = "The field '$name' must contain a positive number"; } + + if (!empty($post['quick_abort_min'])) { + $value = trim($post['quick_abort_min']); + if (!is_numeric($value)) + $input_errors[] = "The field 'Finish when remaining KB' must contain a positive number"; + } + + if (!empty($post['quick_abort_max'])) { + $value = trim($post['quick_abort_max']); + if (!is_numeric($value)) + $input_errors[] = "The field 'Abort when remaining KB' must contain a positive number"; + } + + if (!empty($post['quick_abort_pct'])) { + $value = trim($post['quick_abort_pct']); + if (!is_numeric($value) || ($value > 100)) + $input_errors[] = "The field 'Finish when remaining %' must contain a percentaged value"; + } + } function squid_validate_auth($post, $input_errors) { @@ -700,6 +719,10 @@ function squid_resync_traffic() { $conf .= "request_body_max_size $up_limit KB\n"; $conf .= 'reply_body_max_size ' . ($down_limit * 1024) . " allow all\n"; + if (!empty($settings['quick_abort_min'])) $conf .= "quick_abort_min {$settings['quick_abort_min']} KB\n"; + if (!empty($settings['quick_abort_max'])) $conf .= "quick_abort_max {$settings['quick_abort_max']} KB\n"; + if (!empty($settings['quick_abort_pct'])) $conf .= "quick_abort_pct {$settings['quick_abort_pct']}\n"; + // Only apply throttling past 10MB // XXX: Should this really be hardcoded? $threshold = 10 * 1024 * 1024; diff --git a/packages/squid/squid_traffic.xml b/packages/squid/squid_traffic.xml index 1556be66..1330cac9 100644 --- a/packages/squid/squid_traffic.xml +++ b/packages/squid/squid_traffic.xml @@ -146,6 +146,27 @@ input 60 + + Finish transfer if less than x KB remaining + quick_abort_min + If the transfer has less than x KB remaining, it will finish the retrieval. Set to 0 to abort the transfer immediately. + input + 0 + + + Abort transfer if more than x KB remaining + quick_abort_max + If the transfer has more than x KB remaining, it will abort the retrieval. Set to 0 to abort the transfer immediately. + input + 0 + + + Finish transfer if more than x % finished + quick_abort_pct + If more than x % of the transfer has completed, it will finish the retrieval. + input + 0 + squid_validate_traffic($_POST, &$input_errors); -- cgit v1.2.3