]> git.ipfire.org Git - thirdparty/squid.git/commit
High precision time units (#443)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Thu, 20 Feb 2020 21:13:27 +0000 (21:13 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 21 Feb 2020 02:30:34 +0000 (02:30 +0000)
commit8da861a50ed63acecd111b3810b1a2c806aa8b68
tree83dd1bd201a8f2e79dfe613e8285f16ac74892ec
parent7d17a6a6e75d76e71249ac1ac4afc788c21db6f3
High precision time units (#443)

This patch introduces new time units of microsecond and
nanosecond precision forming a new 'time-units-small' category.

Also found and fixed several problems, related to time parameters
parsing:

* Obscure "integer overflow" fatal messages. For example, passing
  "0.0001 second" caused this message. After fixing, Squid reports
  that the value "is too small to be used in this context".

* Ignoring possible zero-rounded values after parsing. For example, if
  a second-precision parameter was configured with 0.1 second, it
  became zero after rounding, which is unexpected. It is treated
  as a fatal error now.

* Inconsistent parameter overflow type. For example, parameters
  with millisecond and second precision reported that 'time_msec_t'
  overflowed. Now we introduce an absolute time maximum allowed,
  equal to the maximum of chrono::nanoseconds type which is about
  293 years. This absolute maximum allows to keep the time parsing
  code simple and at the same time should satisfy any reasonable
  configuration need. Note that this solution treats existing
  configurations with unreasonably huge time values > 293 years
  as fatal errors, such configurations should be fixed accordingly.

* Time overflows for icap_service_failure_limit parameter were not
  checked at all. This is probably a result of code duplication.
  By fixing the latter problem, the former one was resolved
  automatically.

* Unclear fatal message if a time parameter lacked time unit. Now
  Squid reports about "missing time unit".

* Improved error reporting when an inapplicable time unit was used, for
  example a 'millisecond' instead of a 'second'. For the majority of
  time parameters, it reported only a common "FATAL: Bungled..."
  message. For url_rewrite_timeout parameter, it reported an irrelevant
  "unsupported option ..." message (since it began to treat the faulty
  time unit as the next option). Now in both cases it reports about the
  underlying time unit problem.

While fixing these bugs I had to refactor and improve time parsing
functions, using safer std::chrono types instead of raw integer types.
src/cache_cf.cc
src/cf.data.pre
test-suite/squidconf/time_units [new file with mode: 0644]