]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
4 years agoBUILD: makefile: add a few popular ARMv8 CPU targets
Willy Tarreau [Wed, 12 May 2021 07:47:30 +0000 (09:47 +0200)] 
BUILD: makefile: add a few popular ARMv8 CPU targets

This adds the following CPUs to the makefile:
  - armv81    : modern ARM cores (Cortex A55/A75/A76/A78/X1, Neoverse, Graviton2)
  - a72       : ARM Cortex-A72 or A73 (e.g. RPi4, Odroid N2, VIM3, AWS Graviton)
  - a53       : ARM Cortex-A53 or any of its successors in 64-bit mode (e.g. RPi3)
  - armv8-auto: both older and newer ARMv8 cores, with a minor runtime penalty

The reasons for these ones are:
  - a53 is the common denominator of all of its successors, and does
    support CRC32 which is used by the gzip compression, that the generic
    armv8-a does not ;

  - a72 supports the same features but is an out-of-order one that deserves
    better optimizations; it's found in a number of high-performance
    multi-core CPUs mainly oriented towards I/O and network processing
    (Armada 8040, NXP LX2160A, AWS Graviton), and more recently the
    Raspberry Pi 4. The A73 found in VIM3 and Odroid-N2 can use the same
    optimizations ;

  - armv81 is for generic ARMv8.1-A and above, automatically enables LSE
    atomics which are way more scalable, and CRC32. This one covers modern
    ARMv8 cores such as Cortex A55/A75/A76/A77/A78/X1 and the Neoverse
    family such as found in AWS's Graviton2. The LSE instructions are
    essential for large numbers of cores (8 and above).

  - armv8-auto dynamically enables support for LSE extensions when
    detected while still being compatible with older cores. There is a
    small performance penalty in doing this (~3%) but a same executable
    will perform optimally on a wider range of hardware. This should be
    the best option for distros. It requires gcc-10 or gcc-9.4 and above.

When no CPU is specified, GCC version 10.2 and above will automatically
implement the wrapper used to detect the LSE extensions.

4 years agoBUILD/MINOR: opentracing: fixed compilation with filter enabled
Miroslav Zagorac [Tue, 11 May 2021 17:21:54 +0000 (19:21 +0200)] 
BUILD/MINOR: opentracing: fixed compilation with filter enabled

The inclusion of header files proxy.h and tools.h was added to the
addons/ot/include/include.h file.  Without this HAProxy cannot be
compiled if the OpenTracing filter is to be used.

4 years agoIMPORT: slz: do not produce the crc32_fast table when CRC is natively supported
Willy Tarreau [Wed, 12 May 2021 06:36:09 +0000 (08:36 +0200)] 
IMPORT: slz: do not produce the crc32_fast table when CRC is natively supported

On ARM with native CRC support, no need to inflate the executable with
a 4kB CRC table, let's just drop it.

This is slz upstream commit d8715db20b2968d1f3012a734021c0978758f911.

4 years agoIMPORT: slz: use the generic function for the last bytes of the crc32
Willy Tarreau [Wed, 12 May 2021 06:34:36 +0000 (08:34 +0200)] 
IMPORT: slz: use the generic function for the last bytes of the crc32

This is the only place where we conditionally use the crc32_fast table,
better call the crc32_char inline function for this. This should also
reduce by ~1kB the L1 cache footprint of the compression when dealing
with small blocks, and at least shows a consistent 0.5% perf improvement.

This is slz upstream commit 075351b6c2513b548bac37d6582e46855bc7b36f.

4 years agoMINOR: uri_normalizer: Add `fragment-encode` normalizer
Tim Duesterhus [Mon, 10 May 2021 15:28:26 +0000 (17:28 +0200)] 
MINOR: uri_normalizer: Add `fragment-encode` normalizer

This normalizer encodes '#' as '%23'.

See GitHub Issue #714.

4 years agoMINOR: uri_normalizer: Add `fragment-strip` normalizer
Tim Duesterhus [Mon, 10 May 2021 15:28:25 +0000 (17:28 +0200)] 
MINOR: uri_normalizer: Add `fragment-strip` normalizer

This normalizer strips the URI's fragment component which should never be sent
to the server.

See GitHub Issue #714.

4 years agoBUG/MINOR: http_act: Fix normalizer names in error messages
Tim Duesterhus [Mon, 10 May 2021 21:21:20 +0000 (23:21 +0200)] 
BUG/MINOR: http_act: Fix normalizer names in error messages

These places were forgotten when the normalizers were renamed.

Bug introduced in 5be6ab269e5606aef954f39d6717b024f97b3789, which is 2.4.
No backport needed.

4 years agoCLEANUP: pattern: remove the unused and dangerous pat_ref_reload()
Willy Tarreau [Tue, 11 May 2021 14:49:55 +0000 (16:49 +0200)] 
CLEANUP: pattern: remove the unused and dangerous pat_ref_reload()

This function was not used anymore after the atomic updates were
implemented in 2.3, and it must not be used given that it does not
yield and can easily make the process hang for tens of seconds on
large acls/maps. Let's remove it before someone uses it as an
example to implement something else!

4 years agoMINOR: memprof: also report the totals and delta alloc-free
Willy Tarreau [Tue, 11 May 2021 12:06:24 +0000 (14:06 +0200)] 
MINOR: memprof: also report the totals and delta alloc-free

Already had to perform too many additions by external scripts, it's
time to add the totals and delay alloc-free as a last line in the
output of the "show memory profiling".

4 years agoMINOR: memprof: also report the method used by each call
Willy Tarreau [Tue, 11 May 2021 07:26:23 +0000 (09:26 +0200)] 
MINOR: memprof: also report the method used by each call

This was planned but missing in the previous attempt, we really need to
see what is used at each place, especially due to realloc(). Now we
print the function used in front of the caller's address, as well as
the average alloc/free size per call.

4 years agoBUG/MINOR: memprof: properly account for differences for realloc()
Willy Tarreau [Tue, 11 May 2021 07:12:56 +0000 (09:12 +0200)] 
BUG/MINOR: memprof: properly account for differences for realloc()

The realloc() function checks if the size grew or reduced in order to
count an allocation or a free, but it does so with the absolute (new
or old) value instead of the difference, resulting in realloc() often
being credited for allocating too much.

No backport is needed.

4 years agoCLEANUP: assorted typo fixes in the code and comments
Ilya Shipitsin [Mon, 10 May 2021 07:50:00 +0000 (12:50 +0500)] 
CLEANUP: assorted typo fixes in the code and comments

This is 23rd iteration of typo fixes

4 years agoCI: extend spellchecker whitelist, add "ists" as well
Ilya Shipitsin [Mon, 10 May 2021 07:45:18 +0000 (12:45 +0500)] 
CI: extend spellchecker whitelist, add "ists" as well

codespell does not handle plurals, we already whitelusted "ist", let us
whitelist "ists" as well

4 years agoCI: Build VTest with clang
Tim Duesterhus [Mon, 10 May 2021 20:54:31 +0000 (22:54 +0200)] 
CI: Build VTest with clang

Current VTest master fails to build using gcc, see vtest/VTest#27.

This patch is to be reverted once VTest is fixed.

4 years agoCLEANUP: cli/activity: Remove double spacing in set profiling command
Daniel Corbett [Mon, 10 May 2021 18:08:40 +0000 (14:08 -0400)] 
CLEANUP: cli/activity: Remove double spacing in set profiling command

It was found that when viewing the help output from the CLI that
"set profiling" had 2 spaces in it, which was pushing it out from
the rest of similar commands.

i.e. it looked like this:
  prepare acl <acl>
  prepare map <acl>
  set  profiling  <what>  {auto|on|off}
  set dynamic-cookie-key backend <bk> <k>
  set map <map> [<key>|#<ref>] <value>
  set maxconn frontend <frontend> <value>

This patch removes all of the double spaces within the command and
unifies them to single spacing, which is what is observed within the
rest of the commands.

4 years agoBUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port
Amaury Denoyelle [Mon, 10 May 2021 09:23:34 +0000 (11:23 +0200)] 
BUG/MINOR: http_fetch: fix possible uninit sockaddr in fetch_url_ip/port

Check the return value of url2sa in smp_fetch_url_ip/port. If negative,
the address result is uninitialized and the sample fetch is aborted.
Also, the sockaddr is prelimiary zero'ed before calling url2sa to ensure
that it is not used by upper functions even if the sample returns 0.

Without the check, the value returned by the url_ip/url_port fetches is
unspecified. This can be triggered with the following curl :
$ curl -iv --request-target "xxx://127.0.0.1:20080/" http://127.0.0.1:20080/

This should be backported to all stable branches. However, note that
between the 1.8 and 2.0, the targetted functions have been extracted
from proto_http.c to http_fetch.c.

This should fix in part coverity report from the github issue #1244.

4 years ago[RELEASE] Released version 2.4-dev19 v2.4-dev19
Willy Tarreau [Mon, 10 May 2021 05:50:26 +0000 (07:50 +0200)] 
[RELEASE] Released version 2.4-dev19

Released version 2.4-dev19 with the following main changes :
    - BUG/MINOR: hlua: Don't rely on top of the stack when using Lua buffers
    - BUG/MEDIUM: cli: prevent memory leak on write errors
    - BUG/MINOR: ssl/cli: fix a lock leak when no memory available
    - MINOR: debug: add a new "debug dev sym" command in expert mode
    - MINOR: pools/debug: slightly relax DEBUG_DONT_SHARE_POOLS
    - CI: Github Actions: switch to LibreSSL-3.3.3
    - MINOR: srv: close all idle connections on shutdown
    - MINOR: connection: move session_list member in a union
    - MEDIUM: mux_h1: release idling frontend conns on soft-stop
    - MEDIUM: connection: close front idling connection on soft-stop
    - MINOR: tools: add functions to retrieve the address of a symbol
    - CLEANUP: activity: mark the profiling and task_profiling_mask __read_mostly
    - MINOR: activity: add a "memory" entry to "profiling"
    - MINOR: activity: declare the storage for memory usage statistics
    - MEDIUM: activity: collect memory allocator statistics with USE_MEMORY_PROFILING
    - MINOR: activity: clean up the show profiling io_handler a little bit
    - MINOR: activity: make "show profiling" support a few arguments
    - MINOR: activity: make "show profiling" also dump the memoery usage
    - MINOR: activity: add the profiling.memory global setting
    - BUILD: makefile: add new option USE_MEMORY_PROFILING
    - MINOR: channel: Rely on HTX version if appropriate in channel_may_recv()
    - BUG/MINOR: stream-int: Don't block reads in si_update_rx() if chn may receive
    - MINOR: conn-stream: Force mux to wait for read events if abortonclose is set
    - MEDIUM: mux-h1: Don't block reads when waiting for the other side
    - BUG/MEDIUM: mux-h1: Properly report client close if abortonclose option is set
    - REGTESTS: Add script to test abortonclose option
    - MINOR: mux-h1: clean up conditions to enabled and disabled splicing
    - MINOR: mux-h1: Subscribe for sends if output buffer is not empty in h1_snd_pipe
    - MINOR: mux-h1: Always subscribe for reads when splicing is disabled
    - MEDIUM: mux-h1: Wake H1 stream when both sides a synchronized
    - CLEANUP: mux-h1: rename WAIT_INPUT/WAIT_OUTPUT flags
    - MINOR: mux-h1: Manage processing blocking flags on the H1 stream
    - BUG/MINOR: stream: Decrement server current session counter on L7 retry
    - BUG/MINOR: config: fix uninitialized initial state in ".if" block evaluator
    - BUG/MINOR: config: add a missing "ELIF_TAKE" test for ".elif" condition evaluator
    - BUG/MINOR: config: .if/.elif should also accept negative integers
    - MINOR: config: centralize the ".if"/".elif" condition parser and evaluator
    - MINOR: config: keep up-to-date current file/line/section in the global struct
    - MINOR: config: support some pseudo-variables for file/line/section
    - BUILD: activity: do not include malloc.h
    - MINOR: arg: improve the error message on missing closing parenthesis
    - MINOR: global: export the build features string list
    - MINOR: global: add version comparison functions
    - MINOR: config: improve .if condition error reporting
    - MINOR: config: make cfg_eval_condition() support predicates with arguments
    - MINOR: config: add predicate "defined()" to conditional expression blocks
    - MINOR: config: add predicates "streq()" and "strneq()" to conditional expressions
    - MINOR: config: add predicate "feature" to detect certain built-in features
    - MINOR: config: add predicates "version_atleast" and "version_before" to cond blocks
    - BUG/MINOR: activity: use the new pointer to calculate the new size in realloc()
    - BUG/MINOR: stream: properly clear the previous error mask on L7 retries
    - MEDIUM: log: slightly refine the output format of alerts/warnings/etc
    - MINOR: config: add a new message directive: .diag
    - CLEANUP: cli/tree-wide: properly re-align the CLI commands' help messages
    - BUG/MINOR: stream: Reset stream final state and si error type on L7 retry
    - BUG/MINOR: checks: Handle synchronous connect when a tcpcheck is started
    - BUG/MINOR: checks: Reschedule check on observe mode only if fastinter is set
    - MINOR: global: define tainted flag
    - MINOR: cfgparse: add a new field flags in cfg_keyword
    - MINOR: cfgparse: implement experimental config keywords
    - MINOR: action: replace match_pfx by a keyword flags field
    - MINOR: action: implement experimental actions
    - MINOR: cli: set tainted when using CLI expert/experimental mode
    - MINOR: stats: report tainted on show info
    - MINOR: http_act: mark normalize-uri as experimental
    - BUILD: fix usage of ha_alert without format string
    - MINOR: proxy: define PR_CAP_LB
    - BUG/MINOR: server: do not report diag for peer servers with null weight
    - DOC: ssl: Extra files loading now works for backends too
    - ADDONS: make addons/ discoverable by git via .gitignore
    - DOC: ssl: Add information about crl-file option
    - MINOR: sample: improve error reporting on missing arg to strcmp() converter
    - DOC: management: mention that some fields may be emitted as floats
    - MINOR: tools: implement trimming of floating point numbers
    - MINOR: tools: add a float-to-ascii conversion function
    - MINOR: freq_ctr: add new functions to report float measurements
    - MINOR: stats: avoid excessive padding of float values with trailing zeroes
    - MINOR: stats: add the HTML conversion for float types
    - MINOR: stats: pass the appctx flags to stats_fill_info()
    - MINOR: stats: support an optional "float" option to "show info"
    - MINOR: stats: use tv_remain() to precisely compute the uptime
    - MINOR: stats: report uptime and start time as floats with subsecond resolution
    - MINOR: stats: make "show info" able to report rates as floats when asked
    - MINOR: config: mark tune.fd.edge-triggered as experimental
    - REORG: vars: move the "proc" scope variables out of the global struct
    - REORG: threads: move all_thread_mask() to thread.h
    - BUILD: wdt: include signal-t.h
    - BUILD: auth: include missing list.h
    - REORG: mworker: move proc_self from global to mworker
    - BUILD: ssl: ssl_utils requires chunk.h
    - BUILD: config: cfgparse-ssl.c needs tools.h
    - BUILD: wurfl: wurfl.c needs tools.h
    - BUILD: spoe: flt_spoe.c needs tools.h
    - BUILD: promex: service-prometheus.c needs tools.h
    - BUILD: resolvers: include tools.h
    - BUILD: config: include tools.h in cfgparse-listen.c
    - BUILD: htx: include tools.h in http_htx.c
    - BUILD: proxy: include tools.h in proxy.c
    - BUILD: session: include tools.h in session.c
    - BUILD: cache: include tools.h in cache.c
    - BUILD: sink: include tools.h in sink.c
    - BUILD: connection: include tools.h in connection.c
    - BUILD: server-state: include tools.h from server_state.c
    - BUILD: dns: include tools.h in dns.c
    - BUILD: payload: include tools.h in payload.c
    - BUILD: vars: include tools.h in vars.c
    - BUILD: compression: include tools.h in compression.c
    - BUILD: mworker: include tools.h from mworker.c
    - BUILD: queue: include tools.h from queue.c
    - BUILD: udp: include tools.h from proto_udp.c
    - BUILD: stick-table: include freq_ctr.h from stick_table.h
    - BUILD: server: include tools.h from server.c
    - BUILD: server: include missing proxy.h in server.c
    - BUILD: sink: include proxy.h in sink.c
    - BUILD: mworker: include proxy.h in mworker.c
    - BUILD: filters: include proxy.h in filters.c
    - BUILD: fcgi-app: include proxy.h in fcgi-app.c
    - BUILD: connection: move list_mux_proto() to connection.c
    - REORG: stick-table: uninline stktable_alloc_data_type()
    - REORG: stick-table: move composite address functions to stick_table.h
    - REORG: config: uninline warnifnotcap() and failifnotcap()
    - BUILD: task: remove unused includes from task.c
    - MINOR: task: stop including stream.h from task.c
    - BUILD: connection: stop including listener-t.h
    - BUILD: hlua: include proxy.h from hlua.c
    - BUILD: mux-h1: include proxy.h from mux-h1.c
    - BUILD: mux-fcgi: include proxy.h from mux-fcgi.c
    - BUILD: listener: include proxy.h from listener.c
    - BUILD: http-rules: include proxy.h from http_rules.c
    - BUILD: thread: include log.h from thread.c
    - BUILD: comp: include proxy.h from flt_http_comp.c
    - BUILD: fd: include log.h from fd.c
    - BUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h
    - BUILD: makefile: reorder object files by build time
    - DOC: Fix a few grammar/spelling issues and casing of HAProxy
    - REGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version
    - MINOR: version: report "HAProxy" not "HA-Proxy" in the version output
    - DOC: remove last occurrences of "HA-Proxy" syntax
    - DOC: peers: fix the protocol tag name in the doc
    - ADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions
    - MEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages
    - DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments
    - MINOR: tools/rnd: compute the result outside of the CAS loop
    - BUILD: http_fetch: address a few aliasing warnings with older compilers
    - BUILD: ssl: define HAVE_CRYPTO_memcmp() based on the library version
    - BUILD: errors: include stdarg in errors.h
    - REGTESTS: disable inter-thread idle connection sharing on sensitive tests
    - MINOR: cli: make "help" support a command in argument
    - MINOR: cli: sort the output of the "help" keywords
    - CLEANUP: cli/mworker: properly align the help messages
    - BUILD: memprof: make the old caller pointer a const in get_prof_bin()
    - BUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD
    - CI: Github Actions: enable USE_QUIC=1 for BoringSSL builds
    - BUG/MEDIUM: quic: fix null deref on error path in qc_conn_init()
    - BUILD: cli: appease a null-deref warning in cli_gen_usage_msg()

4 years agoBUILD: cli: appease a null-deref warning in cli_gen_usage_msg()
Willy Tarreau [Mon, 10 May 2021 05:47:05 +0000 (07:47 +0200)] 
BUILD: cli: appease a null-deref warning in cli_gen_usage_msg()

The compiler sees the possibility of null-deref for which a path is
possible but which doesn't exist as we didn't pass a null args outside
of the help request. The test was introduced by the simplified test on
ishelp variable, so let's add it to shut the warning.

4 years agoBUG/MEDIUM: quic: fix null deref on error path in qc_conn_init()
Willy Tarreau [Mon, 10 May 2021 05:40:27 +0000 (07:40 +0200)] 
BUG/MEDIUM: quic: fix null deref on error path in qc_conn_init()

When ctx is NULL, we go to the "err" label, which could dereference it.
No backport is needed.

4 years agoCI: Github Actions: enable USE_QUIC=1 for BoringSSL builds
Ilya Shipitsin [Sun, 9 May 2021 16:27:28 +0000 (21:27 +0500)] 
CI: Github Actions: enable USE_QUIC=1 for BoringSSL builds

if haproxy is built against BoringSSL, let us add USE_QUIC=1 dynamically

4 years agoBUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD
Willy Tarreau [Sun, 9 May 2021 21:46:45 +0000 (23:46 +0200)] 
BUILD: compat: include malloc_np.h for USE_MEMORY_PROFILING on FreeBSD

This include is needed for malloc_usable_size(). It's also important to
think about disabling global pools.

4 years agoBUILD: memprof: make the old caller pointer a const in get_prof_bin()
Willy Tarreau [Sun, 9 May 2021 21:18:50 +0000 (23:18 +0200)] 
BUILD: memprof: make the old caller pointer a const in get_prof_bin()

It's a const void* in the target, we can't use a void* in the caller,
this causes a build warning with clang.

4 years agoCLEANUP: cli/mworker: properly align the help messages
Willy Tarreau [Sun, 9 May 2021 20:49:44 +0000 (22:49 +0200)] 
CLEANUP: cli/mworker: properly align the help messages

CLI help commands were re-aligned by commit b205bfdab but the
master-worker ones were not done, let's do it now.

4 years agoMINOR: cli: sort the output of the "help" keywords
Willy Tarreau [Sun, 9 May 2021 19:45:29 +0000 (21:45 +0200)] 
MINOR: cli: sort the output of the "help" keywords

It's still very difficult to find all commands starting with a given
keyword like "set", "show" etc. Let's sort the lines by usage message,
this is much more convenient.

4 years agoMINOR: cli: make "help" support a command in argument
Willy Tarreau [Sun, 9 May 2021 18:59:23 +0000 (20:59 +0200)] 
MINOR: cli: make "help" support a command in argument

With ~100 commands on the CLI, it's particularly difficult to find a
specific one in the "help" output. The function used to display the
help already supports filtering on certain commands, so in the end it's
just needed to pass the argument of the help command to enable the
automatic filtering. That's what this patch does so that "help clear"
only lists commands starting with "clear" and that "help map" lists
commands containing "map" in them.

4 years agoREGTESTS: disable inter-thread idle connection sharing on sensitive tests
Willy Tarreau [Sun, 9 May 2021 12:41:41 +0000 (14:41 +0200)] 
REGTESTS: disable inter-thread idle connection sharing on sensitive tests

Some regtests involve multiple requests from multiple clients, which can
be dispatched as multiple requests to a server. It turns out that the
idle connection sharing works so well that very quickly few connections
are used, and regularly some of the remaining idle server connections
time out at the moment they were going to be reused, causing those random
"HTTP header incomplete" traces in the logs that make them fail often. In
the end this is only an artefact of the test environment.

And indeed, some tests like normalize-uri which perform a lot of reuse
fail very often, about 20-30% of the times in the CI, and 100% of the
time in local when running 1000 tests in a row. Others like ubase64,
sample_fetches or vary_* fail less often but still a lot in tests.

This patch addresses this by adding "tune.idle-pool.shared off" to all
tests which have at least twice as many requests as clients. It proves
very effective as no single error happens on normalize-uri anymore after
10000 tests. Also 100 full runs of all tests yield no error anymore.

One test is tricky, http_abortonclose, it used to fail ~10 times per
1000 runs and with this workaround still fails once every 1000 runs.
But the test is complex and there's a warning in it mentioning a
possible issue when run in parallel due to a port reuse.

4 years agoBUILD: errors: include stdarg in errors.h
Willy Tarreau [Sun, 9 May 2021 10:04:09 +0000 (12:04 +0200)] 
BUILD: errors: include stdarg in errors.h

It's needed for va_list as defined in ha_vdiag_warning().

4 years agoBUILD: ssl: define HAVE_CRYPTO_memcmp() based on the library version
Willy Tarreau [Sun, 9 May 2021 09:59:49 +0000 (11:59 +0200)] 
BUILD: ssl: define HAVE_CRYPTO_memcmp() based on the library version

The build fails on versions older than 1.0.1d which is the first one
introducing CRYPTO_memcmp(), so let's have a define for this instead
of enabling it whenever USE_OPENSSL is set. One could also wonder why
we're relying on openssl for such a trivial thing, and a simple local
implementation could also allow to restore lexicographic ordering.

4 years agoBUILD: http_fetch: address a few aliasing warnings with older compilers
Willy Tarreau [Sun, 9 May 2021 08:32:54 +0000 (10:32 +0200)] 
BUILD: http_fetch: address a few aliasing warnings with older compilers

gcc-4.4 complains about aliasing in smp_fetch_url_port() and
smp_fetch_url_ip() because the local addr variable is casted to sturct
sockaddr_in before being checked. The family should be checked on the
sockaddr_storage and we have a function to retrieve the port.
The compiler still sees some warnings but these ones are OK now.

4 years agoMINOR: tools/rnd: compute the result outside of the CAS loop
Willy Tarreau [Sun, 9 May 2021 08:26:14 +0000 (10:26 +0200)] 
MINOR: tools/rnd: compute the result outside of the CAS loop

ha_random64() uses a DWCAS loop to produce the random, but it computes
the resulting value inside the loop while it doesn't change upon success,
so this is a needless overhead inside the critcal path that participates
to making threads fail the race and try again. Let's take the value out
of the loop.

4 years agoDOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments
Willy Tarreau [Sun, 9 May 2021 04:47:26 +0000 (06:47 +0200)] 
DOC: fix a few remainig cases of "Haproxy" and "HAproxy" in doc and comments

Some of the Lua doc and a few places still used "Haproxy" or "HAproxy".
There was even one "HA proxy". A few of them were in an example of VTest
output, indicating that VTest ought to be fixed as well. No big deal but
better address all the remaining ones so that these inconsistencies stop
spreading around.

4 years agoMEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages
Willy Tarreau [Sun, 9 May 2021 04:45:16 +0000 (06:45 +0200)] 
MEDIUM: mailers: use "HAProxy" nor "HAproxy" in the subject of messages

It seems to be the last visible casing inconsistency, but better address
it for completeness otherwise we'll always have to deal with some
exceptions.

4 years agoADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions
Willy Tarreau [Sun, 9 May 2021 04:41:37 +0000 (06:41 +0200)] 
ADMIN: netsnmp: report "HAProxy" and not "Haproxy" in output descriptions

In the SNMP fields descriptions, "Haproxy" was mentioned, let's make it
consistent with the rest.

4 years agoDOC: peers: fix the protocol tag name in the doc
Willy Tarreau [Sun, 9 May 2021 04:38:07 +0000 (06:38 +0200)] 
DOC: peers: fix the protocol tag name in the doc

The peers protocol has been using "HAProxyS" as a binary tag sent on the
wire since day one in 1.5-dev3 with commit 2b920a1af ("[MAJOR] Add new
files src/peer.c, include/proto/peers.h and include/types/peers.h for
sync stick table management"), regardless, the doc says the protocol
identifier is "HaproxyS". It is likely this got fixed in the code before
merging and not in the doc.

This should be backported to any release as the doc is wrong.

4 years agoDOC: remove last occurrences of "HA-Proxy" syntax
Willy Tarreau [Sun, 9 May 2021 04:25:16 +0000 (06:25 +0200)] 
DOC: remove last occurrences of "HA-Proxy" syntax

There were only a few more used as output examples and comments in a few
docs, it was the right moment to get rid of them. The file intro.txt
which explains how to parse the version also got a hint about the possible
presence of a hyphen in the name in older versions.

4 years agoMINOR: version: report "HAProxy" not "HA-Proxy" in the version output
Willy Tarreau [Sun, 9 May 2021 04:14:25 +0000 (06:14 +0200)] 
MINOR: version: report "HAProxy" not "HA-Proxy" in the version output

When running "haproxy -v", we still get "HA-Proxy" which is the last
place where this confusing oddity happens. Being so used to it I didn't
even notice it until it was reported to me just after 2.2 but it never
got fixed, despite the PRODUCT_NAME macro that is used to report the
name in the stats page and in "show info" being already set to "HAProxy"
15 years ago in 1.2.14 with commit e03312613. It's about time to
uniformize everything.

4 years agoREGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version
Willy Tarreau [Sun, 9 May 2021 04:12:41 +0000 (06:12 +0200)] 
REGTESTS: run-regtests: match both "HAProxy" and "HA-Proxy" in the version

The script checks the HAProxy version and was looking for "HA-Proxy" which
is hard-coded in haproxy.c, let's relax the test to also accept "HAProxy".

4 years agoDOC: Fix a few grammar/spelling issues and casing of HAProxy
Daniel Corbett [Sat, 8 May 2021 14:50:37 +0000 (10:50 -0400)] 
DOC: Fix a few grammar/spelling issues and casing of HAProxy

This patch fixes a few grammar and spelling issues in configuration.txt.
It was also noted that there was a wide range of case usage
(i.e. haproxy, HAproxy, HAProxy, etc... ). This patch updates them
all to be consistently "HAProxy" except where a binary is mentioned.

4 years agoBUILD: makefile: reorder object files by build time
Willy Tarreau [Sat, 8 May 2021 21:33:25 +0000 (23:33 +0200)] 
BUILD: makefile: reorder object files by build time

This is the per-release reordering to improve build parallelism.
It didn't change much, mostly dns+resolvers inflated this time.
Nowadays build times are mostly dominated by the long dependencies
of include files, no less than 170MB of preprocessed code has to be
built, and half of this is SSL support is disabled. Includes should
likely be reworked to be smaller with less dependencies each,
possibly splitting what's the core of each of them and what is used
to interface with other ones. Each split of a .C file in two adds
0.3s of build time just because of this.

4 years agoBUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h
Willy Tarreau [Sat, 8 May 2021 18:25:57 +0000 (20:25 +0200)] 
BUILD: config: do not include proxy.h nor errors.h anymore in cfgparse.h

These ones induce a long dependency chain and are not needed anymore.

4 years agoBUILD: fd: include log.h from fd.c
Willy Tarreau [Sat, 8 May 2021 18:35:03 +0000 (20:35 +0200)] 
BUILD: fd: include log.h from fd.c

It's needed for ha_alert() and the header was missing.

4 years agoBUILD: comp: include proxy.h from flt_http_comp.c
Willy Tarreau [Sat, 8 May 2021 18:34:16 +0000 (20:34 +0200)] 
BUILD: comp: include proxy.h from flt_http_comp.c

It's used for proxy_type_str() but the header was missing.

4 years agoBUILD: thread: include log.h from thread.c
Willy Tarreau [Sat, 8 May 2021 18:33:02 +0000 (20:33 +0200)] 
BUILD: thread: include log.h from thread.c

It's needed for ha_alert(). Probably that a separate file for error
reporting at boot would be useful.

4 years agoBUILD: http-rules: include proxy.h from http_rules.c
Willy Tarreau [Sat, 8 May 2021 18:30:37 +0000 (20:30 +0200)] 
BUILD: http-rules: include proxy.h from http_rules.c

Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.

4 years agoBUILD: listener: include proxy.h from listener.c
Willy Tarreau [Sat, 8 May 2021 18:30:37 +0000 (20:30 +0200)] 
BUILD: listener: include proxy.h from listener.c

Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.

4 years agoBUILD: mux-fcgi: include proxy.h from mux-fcgi.c
Willy Tarreau [Sat, 8 May 2021 18:28:54 +0000 (20:28 +0200)] 
BUILD: mux-fcgi: include proxy.h from mux-fcgi.c

proxy_capture_error() was called there without the include, which was
inherited via cfgparse.h.

4 years agoBUILD: mux-h1: include proxy.h from mux-h1.c
Willy Tarreau [Sat, 8 May 2021 18:28:54 +0000 (20:28 +0200)] 
BUILD: mux-h1: include proxy.h from mux-h1.c

proxy_capture_error() was called there without the include, which was
inherited via cfgparse.h.

4 years agoBUILD: hlua: include proxy.h from hlua.c
Willy Tarreau [Sat, 8 May 2021 18:28:07 +0000 (20:28 +0200)] 
BUILD: hlua: include proxy.h from hlua.c

Many proxy functions are called there but the include was missing and
inherited via cfgparse.h.

4 years agoBUILD: connection: stop including listener-t.h
Willy Tarreau [Sat, 8 May 2021 18:14:39 +0000 (20:14 +0200)] 
BUILD: connection: stop including listener-t.h

listener-t comes with openssl just due to the SSL_CTX type that is
declred as a typedef in openssl hence cannot be abstracted at this
level. However connection-t.h doen't need all that just to know that
bind_conf is a struct. Let's declare it with other external types
instead..

4 years agoMINOR: task: stop including stream.h from task.c
Willy Tarreau [Sat, 8 May 2021 18:10:13 +0000 (20:10 +0200)] 
MINOR: task: stop including stream.h from task.c

This one comes with a very deep dependency hell, only to know that
process_stream() is a function. Dropping it reduces the preprocessed
output from 1.5MB to 640kB.

4 years agoBUILD: task: remove unused includes from task.c
Willy Tarreau [Sat, 8 May 2021 18:08:58 +0000 (20:08 +0200)] 
BUILD: task: remove unused includes from task.c

freq_ctr.h and time.h are not used, let's drop them.

4 years agoREORG: config: uninline warnifnotcap() and failifnotcap()
Willy Tarreau [Sat, 8 May 2021 17:58:37 +0000 (19:58 +0200)] 
REORG: config: uninline warnifnotcap() and failifnotcap()

These ones are used by virtually every config parser. Not only they
provide no benefit in being inlined, but they imply a very deep
dependency starting at proxy.h, which results for example in task.c
including openssl.

Let's move these two functions to cfgparse.c.

4 years agoREORG: stick-table: move composite address functions to stick_table.h
Willy Tarreau [Sat, 8 May 2021 12:12:47 +0000 (14:12 +0200)] 
REORG: stick-table: move composite address functions to stick_table.h

These caddr_* functions were once placed into tools.h in the hope they
would be useful but nobody knows they exist. They could deserve being
moved to their own file with other pointer manipulation functions maybe,
but for now they're the only reason left for stick_table.h to include
tools.h, so let's move them directly there since it's its only user.
This allows to remove tools.h from stick_table.h and slightly reduce
the overall build time.

4 years agoREORG: stick-table: uninline stktable_alloc_data_type()
Willy Tarreau [Sat, 8 May 2021 12:10:42 +0000 (14:10 +0200)] 
REORG: stick-table: uninline stktable_alloc_data_type()

This function has no business being inlined in stick_table.h since it's
only used at boot time by the config parser. In addition it causes an
undesired dependency on tools.h because it uses parse_time_err(). Let's
move it to stick_table.c.

4 years agoBUILD: connection: move list_mux_proto() to connection.c
Willy Tarreau [Sat, 8 May 2021 12:06:09 +0000 (14:06 +0200)] 
BUILD: connection: move list_mux_proto() to connection.c

No idea why this was put inlined into connection.h, it's used only once
for haproxy -vv, and requires tools.h, causing an undesired dependency
from connection.h. Let's move it to connection.c instead where it ought
to have been.

4 years agoBUILD: fcgi-app: include proxy.h in fcgi-app.c
Willy Tarreau [Sat, 8 May 2021 18:23:18 +0000 (20:23 +0200)] 
BUILD: fcgi-app: include proxy.h in fcgi-app.c

It's needed for proxies_list and used to be inherited via cfgparse.h.

4 years agoBUILD: filters: include proxy.h in filters.c
Willy Tarreau [Sat, 8 May 2021 18:22:17 +0000 (20:22 +0200)] 
BUILD: filters: include proxy.h in filters.c

It's needed for proxies_list and used to be inherited via cfgparse.h.

4 years agoBUILD: mworker: include proxy.h in mworker.c
Willy Tarreau [Sat, 8 May 2021 18:21:31 +0000 (20:21 +0200)] 
BUILD: mworker: include proxy.h in mworker.c

It's needed for proxies_list and used to be inherited via cfgparse.h.

4 years agoBUILD: sink: include proxy.h in sink.c
Willy Tarreau [Sat, 8 May 2021 18:20:21 +0000 (20:20 +0200)] 
BUILD: sink: include proxy.h in sink.c

It's needed for proxies_list but was missing.

4 years agoBUILD: server: include missing proxy.h in server.c
Willy Tarreau [Sat, 8 May 2021 18:18:59 +0000 (20:18 +0200)] 
BUILD: server: include missing proxy.h in server.c

It's needed for a number of functions and definitions but was missing.

4 years agoBUILD: server: include tools.h from server.c
Willy Tarreau [Sat, 8 May 2021 12:09:40 +0000 (14:09 +0200)] 
BUILD: server: include tools.h from server.c

A lot of functions from tools.h are used there but the file was only
inherited via other ones.

4 years agoBUILD: stick-table: include freq_ctr.h from stick_table.h
Willy Tarreau [Sat, 8 May 2021 12:08:38 +0000 (14:08 +0200)] 
BUILD: stick-table: include freq_ctr.h from stick_table.h

It's needed for update_freq_ctr_period() which is used there.

4 years agoBUILD: udp: include tools.h from proto_udp.c
Willy Tarreau [Sat, 8 May 2021 11:59:56 +0000 (13:59 +0200)] 
BUILD: udp: include tools.h from proto_udp.c

A few functions are used from there for address conversion but the
file wasn't included.

4 years agoBUILD: queue: include tools.h from queue.c
Willy Tarreau [Sat, 8 May 2021 11:59:05 +0000 (13:59 +0200)] 
BUILD: queue: include tools.h from queue.c

It uses memprintf() without including the file because it inherited
it from other ones.

4 years agoBUILD: mworker: include tools.h from mworker.c
Willy Tarreau [Sat, 8 May 2021 11:58:19 +0000 (13:58 +0200)] 
BUILD: mworker: include tools.h from mworker.c

It needs it for memprintf() but didn't include the file.

4 years agoBUILD: compression: include tools.h in compression.c
Willy Tarreau [Sat, 8 May 2021 11:57:19 +0000 (13:57 +0200)] 
BUILD: compression: include tools.h in compression.c

It needs it for memprintf() but it wasn't included.

4 years agoBUILD: vars: include tools.h in vars.c
Willy Tarreau [Sat, 8 May 2021 11:56:31 +0000 (13:56 +0200)] 
BUILD: vars: include tools.h in vars.c

A number of functions from tools.h are used there but the file was not
included.

4 years agoBUILD: payload: include tools.h in payload.c
Willy Tarreau [Sat, 8 May 2021 11:55:40 +0000 (13:55 +0200)] 
BUILD: payload: include tools.h in payload.c

It needs it for memprintf() but used to inherit it via other include files.

4 years agoBUILD: dns: include tools.h in dns.c
Willy Tarreau [Sat, 8 May 2021 11:09:46 +0000 (13:09 +0200)] 
BUILD: dns: include tools.h in dns.c

It is used for get_addr_len() without being included. It could be worth
splitting address manipulation functions to a different set of files.

4 years agoBUILD: server-state: include tools.h from server_state.c
Willy Tarreau [Sat, 8 May 2021 11:08:34 +0000 (13:08 +0200)] 
BUILD: server-state: include tools.h from server_state.c

Many functions from tools.h are called there without the file being
included.

4 years agoBUILD: connection: include tools.h in connection.c
Willy Tarreau [Sat, 8 May 2021 11:07:31 +0000 (13:07 +0200)] 
BUILD: connection: include tools.h in connection.c

Several functions from tools.h are called there without the file being
included.

4 years agoBUILD: sink: include tools.h in sink.c
Willy Tarreau [Sat, 8 May 2021 11:05:30 +0000 (13:05 +0200)] 
BUILD: sink: include tools.h in sink.c

Several functions from tools.h are used in sink.c without tools.h being
included.

4 years agoBUILD: cache: include tools.h in cache.c
Willy Tarreau [Sat, 8 May 2021 11:03:55 +0000 (13:03 +0200)] 
BUILD: cache: include tools.h in cache.c

cache.c uses a lot of functions from tools.h without including it.

4 years agoBUILD: session: include tools.h in session.c
Willy Tarreau [Sat, 8 May 2021 11:03:04 +0000 (13:03 +0200)] 
BUILD: session: include tools.h in session.c

The file session.c calls plenty of functions from tools.h but did not
include it.

4 years agoBUILD: proxy: include tools.h in proxy.c
Willy Tarreau [Sat, 8 May 2021 11:02:07 +0000 (13:02 +0200)] 
BUILD: proxy: include tools.h in proxy.c

Many functions are used from tools.h but the file wasn't included and
was inherited through others.

4 years agoBUILD: htx: include tools.h in http_htx.c
Willy Tarreau [Sat, 8 May 2021 11:01:23 +0000 (13:01 +0200)] 
BUILD: htx: include tools.h in http_htx.c

Several functions from tools.h are called there and it used to be
inherited through others.

4 years agoBUILD: config: include tools.h in cfgparse-listen.c
Willy Tarreau [Sat, 8 May 2021 11:00:23 +0000 (13:00 +0200)] 
BUILD: config: include tools.h in cfgparse-listen.c

Many functions defined in tools.h were called there but the file used
to be inherited via others.

4 years agoBUILD: resolvers: include tools.h
Willy Tarreau [Sat, 8 May 2021 10:59:47 +0000 (12:59 +0200)] 
BUILD: resolvers: include tools.h

Many functions from tools.h are called there but it was inherited via others.

4 years agoBUILD: promex: service-prometheus.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:58:12 +0000 (12:58 +0200)] 
BUILD: promex: service-prometheus.c needs tools.h

It calls url_decode() and memprintf() but used to inherit them through
others.

4 years agoBUILD: spoe: flt_spoe.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:57:17 +0000 (12:57 +0200)] 
BUILD: spoe: flt_spoe.c needs tools.h

It uses many functions declared there but used to inherit it through others.

4 years agoBUILD: wurfl: wurfl.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:56:20 +0000 (12:56 +0200)] 
BUILD: wurfl: wurfl.c needs tools.h

It calls memprintf() which is defined there but used to inherit it
through others.

4 years agoBUILD: config: cfgparse-ssl.c needs tools.h
Willy Tarreau [Sat, 8 May 2021 10:54:42 +0000 (12:54 +0200)] 
BUILD: config: cfgparse-ssl.c needs tools.h

It calls parse_time_err() which is defined there but used to inherit it
through others.

4 years agoBUILD: ssl: ssl_utils requires chunk.h
Willy Tarreau [Sat, 8 May 2021 10:52:56 +0000 (12:52 +0200)] 
BUILD: ssl: ssl_utils requires chunk.h

It uses chunk_printf() so it needs it. Currently it gets it through
others.

4 years agoREORG: mworker: move proc_self from global to mworker
Willy Tarreau [Sat, 8 May 2021 10:30:50 +0000 (12:30 +0200)] 
REORG: mworker: move proc_self from global to mworker

Only mworker uses proc_self, and it was declared in global.h, forcing
users of global.h to include mworker and its dependencies.

Moving it to mworker reduces the preprocessed size of version.c from
170 to 125kB by shrinking the number of local includes from 30 to 16
and the number of system includes from 147 to 132.

4 years agoBUILD: auth: include missing list.h
Willy Tarreau [Sat, 8 May 2021 10:29:51 +0000 (12:29 +0200)] 
BUILD: auth: include missing list.h

list_for_each_entry() requires list.h but used to inherit it by accident
through global.h and mworker-t.h. Let's explicitly add it.

4 years agoBUILD: wdt: include signal-t.h
Willy Tarreau [Sat, 8 May 2021 10:27:42 +0000 (12:27 +0200)] 
BUILD: wdt: include signal-t.h

WDT_SIG is used there, thus signal-t.h is required. Currently it's
retrieved by accident through global.h.

4 years agoREORG: threads: move all_thread_mask() to thread.h
Willy Tarreau [Sat, 8 May 2021 10:26:10 +0000 (12:26 +0200)] 
REORG: threads: move all_thread_mask() to thread.h

It was declared in global.h, forcing plenty of source files to include
it only for this while it's only based on definitions from thread.h.

4 years agoREORG: vars: move the "proc" scope variables out of the global struct
Willy Tarreau [Sat, 8 May 2021 09:41:28 +0000 (11:41 +0200)] 
REORG: vars: move the "proc" scope variables out of the global struct

The presence of this field causes a long dependency chain because almost
everyone includes global-t.h, and vars include sample_data which include
some system includes as well as HTTP parts.

There is absolutely no reason for having the process-wide variables in
the global struct, let's just move them into vars.c and vars.h. This
reduces from ~190k to ~170k the preprocessed output of version.c.

4 years agoMINOR: config: mark tune.fd.edge-triggered as experimental
Willy Tarreau [Sat, 8 May 2021 09:06:32 +0000 (11:06 +0200)] 
MINOR: config: mark tune.fd.edge-triggered as experimental

This one is stated as experimental in the doc but could still be used
by accidental copy-paste. Let's mark it with KWF_EXPERIMENTAL so that
users have to opt-in to use it.

4 years agoMINOR: stats: make "show info" able to report rates as floats when asked
Willy Tarreau [Sat, 8 May 2021 06:14:04 +0000 (08:14 +0200)] 
MINOR: stats: make "show info" able to report rates as floats when asked

Now "show info float" will also report SSL rates, connection rates and
key reuse ratios as floats. This can be convenient at very low rates.

Note that the SSL reuse ratio which used to commonly oscillate between
0 and 1 under load is now more often above zero with small values. It
indicates that for better stability we shouldn't be comparing a key rate
with a connection rate but instead we should measure the reuse rate at
its source.

4 years agoMINOR: stats: report uptime and start time as floats with subsecond resolution
Willy Tarreau [Sat, 8 May 2021 05:56:56 +0000 (07:56 +0200)] 
MINOR: stats: report uptime and start time as floats with subsecond resolution

When "show info float" is used, the uptime and start time will be reported
with subsecond resolution (microsecond actually since timeval is used).

4 years agoMINOR: stats: use tv_remain() to precisely compute the uptime
Willy Tarreau [Sat, 8 May 2021 05:40:52 +0000 (07:40 +0200)] 
MINOR: stats: use tv_remain() to precisely compute the uptime

We'll have to support reporting sub-second uptimes, so let's use the
appropriate function which will automatically adjust the tv_usec field.
In addition to this, it will also report a more accurate uptime thanks
to considering the sub-second part in the result.

4 years agoMINOR: stats: support an optional "float" option to "show info"
Willy Tarreau [Sat, 8 May 2021 05:54:24 +0000 (07:54 +0200)] 
MINOR: stats: support an optional "float" option to "show info"

This will allow some fields to be produced with a higher accuracy when
the requester indicates being able to parse floats. Rates and times are
among the elements which can make sense.

4 years agoMINOR: stats: pass the appctx flags to stats_fill_info()
Willy Tarreau [Sat, 8 May 2021 05:43:53 +0000 (07:43 +0200)] 
MINOR: stats: pass the appctx flags to stats_fill_info()

Currently the stats filling function knows nothing about the caller's
needs, so let's pass the STAT_* flags so that it can adapt to the
requester's constraints.

4 years agoMINOR: stats: add the HTML conversion for float types
Willy Tarreau [Sat, 8 May 2021 05:37:38 +0000 (07:37 +0200)] 
MINOR: stats: add the HTML conversion for float types

For the prometheus exporter, a new float type was added for the fields
and its conversion was added everywhere except for the HTML output.
Now that we have F2H() we can implement it for consistency.

4 years agoMINOR: stats: avoid excessive padding of float values with trailing zeroes
Willy Tarreau [Sat, 8 May 2021 08:38:20 +0000 (10:38 +0200)] 
MINOR: stats: avoid excessive padding of float values with trailing zeroes

When emitting stats, we don't need to have 6 zeroes after the decimal point
for each value, so let's trim floating point numbers to the longest needed
only.

4 years agoMINOR: freq_ctr: add new functions to report float measurements
Willy Tarreau [Sat, 8 May 2021 06:12:37 +0000 (08:12 +0200)] 
MINOR: freq_ctr: add new functions to report float measurements

For stats reporting it can be convenient to report floats at low rates
instead of discrete integers. We do have quite some precision since we
currently divide counters by number of milliseconds, so we can usually
add 3 digits after the decimal point.

4 years agoMINOR: tools: add a float-to-ascii conversion function
Willy Tarreau [Sat, 8 May 2021 05:35:00 +0000 (07:35 +0200)] 
MINOR: tools: add a float-to-ascii conversion function

We already had ultoa_r() and friends but nothing to emit inline floats.
This is now done with ftoa_r() and F2A/F2H. Note that the latter both use
the itoa_str[] as temporary storage and that the HTML format currently is
the exact same as the ASCII one. The trailing zeroes are always timmed so
these outputs are usable in user-visible output.

4 years agoMINOR: tools: implement trimming of floating point numbers
Willy Tarreau [Sat, 8 May 2021 08:28:53 +0000 (10:28 +0200)] 
MINOR: tools: implement trimming of floating point numbers

When using "%f" to print a float, it automatically gets 6 digits after
the decimal point and there's no way to automatically adjust to the
required ones by dropping trailing zeroes. This function does exactly
this and automatically drops the decimal point if all digits after it
were zeroes. This will make numbers more friendly in stats and makes
outputs shorter (e.g. JSON where everything is just a "number").

The function is designed to be easy to use with snprint() and chunks:

  snprintf:
    flt_trim(buf, 0, snprintf(buf, sizeof(buf), "%f", x));

  chunk_printf:
    out->data = flt_trim(out->area, 0, chunk_printf(out, "%f", x));

  chunk_appendf:
    size_t prev_data = out->data;
    out->data = flt_trim(out->area, prev_data, chunk_appendf(out, "%f", x));

4 years agoDOC: management: mention that some fields may be emitted as floats
Willy Tarreau [Sat, 8 May 2021 05:46:44 +0000 (07:46 +0200)] 
DOC: management: mention that some fields may be emitted as floats

Floats in stats output are currently not emitted but are technically
possible, so let's mention that.