------------------------------------------------------------ revno: 13661 revision-id: squid3@treenet.co.nz-20141121092514-rbjc5fl5c12empm4 parent: squid3@treenet.co.nz-20141113080356-o2pftaav0xctkgpr committer: Amos Jeffries branch nick: 3.5 timestamp: Fri 2014-11-21 01:25:14 -0800 message: Fix delay_parameters parsing Squid-3.4 parser changes resulted in always getting a BUNGLED error when parsing delay_parameters. Convert to the new ConfigParser engine. Add ability to specify 'none' for no-limit instead of -n/* ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20141121092514-rbjc5fl5c12empm4 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 36519592e81361d3dc615b877d92d9a699050ba1 # timestamp: 2014-11-21 09:37:17 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20141113080356-\ # o2pftaav0xctkgpr # # Begin patch === modified file 'src/DelaySpec.cc' --- src/DelaySpec.cc 2014-09-13 13:59:43 +0000 +++ src/DelaySpec.cc 2014-11-21 09:25:14 +0000 @@ -41,19 +41,31 @@ void DelaySpec::parse() { - int r; - char *token; - token = strtok(NULL, "/"); - + // get the token. + char *token = ConfigParser::NextToken(); if (token == NULL) self_destruct(); - if (sscanf(token, "%d", &r) != 1) - self_destruct(); - - restore_bps = r; - - max_bytes = GetInteger64(); + // no-limit value + if (strcmp(token, "none") == 0 || token[0] == '-') { + restore_bps = -1; + max_bytes = -1; + return; + } + + // parse the first digits into restore_bps + const char *p = NULL; + if (!StringToInt(token, restore_bps, &p, 10) && *p != '/') { + debugs(77, DBG_CRITICAL, "ERROR: invalid delay rate '" << token << "'. Expecting restore/max or 'none'."); + self_destruct(); + } + p++; // increment past the '/' + + // parse the rest into max_bytes + if (!StringToInt64(p, max_bytes, NULL, 10)) { + debugs(77, DBG_CRITICAL, "ERROR: restore rate in '" << token << "' is not a number."); + self_destruct(); + } } #endif === modified file 'src/cf.data.pre' --- src/cf.data.pre 2014-10-17 01:37:34 +0000 +++ src/cf.data.pre 2014-11-21 09:25:14 +0000 @@ -6476,23 +6476,23 @@ description of delay_class. For a class 1 delay pool, the syntax is: - delay_pools pool 1 + delay_class pool 1 delay_parameters pool aggregate For a class 2 delay pool: - delay_pools pool 2 + delay_class pool 2 delay_parameters pool aggregate individual For a class 3 delay pool: - delay_pools pool 3 + delay_class pool 3 delay_parameters pool aggregate network individual For a class 4 delay pool: - delay_pools pool 4 + delay_class pool 4 delay_parameters pool aggregate network individual user For a class 5 delay pool: - delay_pools pool 5 + delay_class pool 5 delay_parameters pool tagrate The option variables are: @@ -6528,11 +6528,11 @@ above example, and is being used to strictly limit each host to 64Kbit/sec (plus overheads), with no overall limit, the line is: - delay_parameters 1 -1/-1 8000/8000 + delay_parameters 1 none 8000/8000 Note that 8 x 8000 KByte/sec -> 64Kbit/sec. - Note that the figure -1 is used to represent "unlimited". + Note that the word 'none' is used to represent no limit. And, if delay pool number 2 is a class 3 delay pool as in the above