haproxy/include/types
Willy Tarreau 1c306aa84d BUG/MEDIUM: random: implement per-thread and per-process random sequences
As mentioned in previous patch, the random number generator was never
made thread-safe, which used not to be a problem for health checks
spreading, until the uuid sample fetch function appeared. Currently
it is possible for two threads or processes to produce exactly the
same UUID. In fact it's extremely likely that this will happen for
processes, as can be seen with this config:

    global
        nbproc 8

    frontend f
        bind :4445
        mode http
        log stdout daemon format raw
        log-format "%[uuid] %pid"
        redirect location /

It typically produces this log:

  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30645
  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30641
  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30644
  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30639
  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30646
  07764439-c24d-4e6f-a5a6-0138be59e7a8 30645
  07764439-c24d-4e6f-a5a6-0138be59e7a8 30639
  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30643
  07764439-c24d-4e6f-a5a6-0138be59e7a8 30646
  b6773fdd-678f-4d04-96f2-4fb11ad15d6b 30646
  551ce567-0bfb-4bbd-9b58-cdc7e9365325 30642
  07764439-c24d-4e6f-a5a6-0138be59e7a8 30642

What this patch does is to use a distinct per-thread and per-process
seed to make sure the same sequences will not appear, and will then
extend these seeds by "burning" a number of randoms that depends on
the global random seed, the thread ID and the process ID. This adds
roughly 20 extra bits of randomness, resulting in 52 bits total per
thread and per process.

It only takes a few milliseconds to burn these randoms and given
that threads start with a different seed, we know they will not
catch each other. So these random extra bits are essentially added
to ensure randomness between boots and cluster instances.

This replaces all uses of random() with ha_random() which uses the
thread-local state.

This must be backported as far as 2.0 or any version having the
UUID sample-fetch function since it's the main victim here.

It's important to note that this patch, in addition to depending on
the previous one "BUG/MEDIUM: init: initialize the random pool a bit
better", also depends on the preceeding build fixes to address a
circular dependency issue in the include files that prevented it
from building. Part or all of these patches may need to be backported
or adapted as well.
2020-03-07 06:11:15 +01:00
..
acl.h REORG/MAJOR: session: rename the "session" entity to "stream" 2015-04-06 11:23:56 +02:00
action.h MEDIUM: http-rules: Support extra headers for HTTP return actions 2020-02-06 15:13:03 +01:00
activity.h MAJOR: fd: Get rid of the fd cache. 2019-07-31 14:12:55 +02:00
applet.h MEDIUM: cli: Allow multiple filter entries for "show table" 2020-01-22 14:33:17 +01:00
arg.h MEDIUM: stick-table: Stop handling stick-tables as proxies. 2019-05-07 06:54:06 +02:00
auth.h MAJOR: auth: Change the internal authentication system. 2014-03-17 18:06:06 +01:00
backend.h MEDIUM: backend: move all LB algo parameters into an union 2019-01-14 19:33:17 +01:00
capture.h CLEANUP: pools: rename all pool functions and pointers to remove this "2" 2017-11-24 17:49:53 +01:00
channel.h CLEANUP: channel: Remove the unused flag CF_WAKE_CONNECT 2019-07-19 09:24:12 +02:00
checks.h BUILD: buffer: types/{ring.h,checks.h} should include buf.h, not buffer.h 2020-03-07 06:07:18 +01:00
cli.h MINOR: cli: add an expert mode to hide dangerous commands 2019-10-24 18:38:00 +02:00
compression.h MAJOR: buffer: finalize buffer detachment 2018-07-19 16:23:43 +02:00
connection.h MINOR: connection: introduce a new receive flag: CO_RFL_READ_ONCE 2020-02-21 11:22:45 +01:00
counters.h MINOR: counters: Remove failed_secu counter and use denied_resp instead 2020-01-20 15:18:45 +01:00
dict.h MINOR: dict: Store the length of the dictionary entries. 2019-06-07 15:47:54 +02:00
dns.h MEDIUM: dns: use Additional records from SRV responses 2020-01-22 07:19:54 +01:00
fcgi-app.h MEDIUM: fcgi-app: Add FCGI application and filter 2019-09-17 10:18:54 +02:00
fd.h MINOR: fd: merge the read and write error bits into RW error 2020-02-28 07:42:29 +01:00
filters.h MEDIUM: filters: Adapt filters API to allow again TCP filtering on HTX streams 2019-11-15 13:43:08 +01:00
freq_ctr.h [MINOR] freq_ctr: add new types and functions for periods different from 1s 2010-08-10 14:01:09 +02:00
global.h BUG/MEDIUM: random: implement per-thread and per-process random sequences 2020-03-07 06:11:15 +01:00
hlua.h MINOR: lua: Remove the flag HLUA_TXN_HTTP_RDY 2020-03-06 14:13:00 +01:00
http_ana.h BUG/MINOR: http_ana: make sure redirect flags don't have overlapping bits 2020-02-27 23:44:41 +01:00
http_htx.h MINOR: http-htx: Add a new section to create groups of custom HTTP errors 2020-01-20 15:18:46 +01:00
lb_chash.h MINOR: backend: move hash_balance_factor out of chash 2019-01-14 19:33:17 +01:00
lb_fas.h MEDIUM: backend: add the 'first' balancing algorithm 2012-02-21 22:27:27 +01:00
lb_fwlc.h [MEDIUM] build: switch ebtree users to use new ebtree version 2009-10-26 21:10:04 +01:00
lb_fwrr.h [MEDIUM] build: switch ebtree users to use new ebtree version 2009-10-26 21:10:04 +01:00
lb_map.h MEDIUM: threads/lb: Make LB algorithms (lb_*.c) thread-safe 2017-10-31 13:58:31 +01:00
listener.h BUILD: listener: types/listener.h must not include standard.h 2020-03-07 06:07:18 +01:00
log.h BUG/MINOR: log: make "show startup-log" use a ring buffer instead 2019-11-15 15:50:16 +01:00
mailers.h MINOR: mailers: make it possible to configure the connection timeout 2016-02-20 15:33:06 +01:00
map.h CLEANUP: map: it seems that the map were planed to be chained 2016-03-30 15:41:15 +02:00
obj_type.h MINOR: obj_type: new object type for struct stream 2019-04-23 11:35:56 +02:00
pattern.h CLEANUP: pattern: remove the pat_time definition 2020-01-22 07:44:36 +01:00
peers.h MINOR: peers: Add debugging information to "show peers". 2019-11-19 14:48:28 +01:00
pipe.h [MEDIUM] introduce pipe pools 2009-01-25 13:49:53 +01:00
port_range.h BUG/MEDIUM: port_range: Make the ring buffer lock-free. 2019-04-30 15:10:17 +02:00
proto_udp.h MEDIUM: protocol: add minimalist UDP protocol client 2015-06-13 22:07:35 +02:00
protocol.h BUG/MEDIUM: protocols: add a global lock for the init/deinit stuff 2019-07-24 16:45:02 +02:00
protocol_buffers.h MINOR: sample: Rework gRPC converter code. 2019-03-05 11:04:23 +01:00
proxy.h MINOR: proxy: Make header_unique_id a struct ist 2020-03-05 19:58:22 +01:00
queue.h MINOR: queue: replace the linked list with a tree 2018-08-10 15:06:27 +02:00
ring.h BUILD: buffer: types/{ring.h,checks.h} should include buf.h, not buffer.h 2020-03-07 06:07:18 +01:00
sample.h MAJOR: http: Remove the HTTP legacy code 2019-07-19 09:24:12 +02:00
server.h MEDIUM: dns: use Additional records from SRV responses 2020-01-22 07:19:54 +01:00
session.h MEDIUM: sessions: Introduce session flags. 2019-05-29 15:41:47 +02:00
shctx.h MINOR: shctx: Change max. object size type to unsigned int. 2018-10-26 04:54:40 +02:00
signal.h [MEDIUM] signals: add support for registering functions and tasks 2010-08-27 18:00:40 +02:00
sink.h MINOR: sink: now report the number of dropped events on output 2019-08-27 17:14:19 +02:00
spoe.h MINOR: spoe: Support the async mode with several threads 2019-09-26 16:51:02 +02:00
ssl_sock.h BUILD: ssl: include mini-clist.h 2020-03-07 06:07:18 +01:00
stats.h MINOR: stats: Report internal errors in the proxies/listeners/servers stats 2020-01-20 15:18:45 +01:00
stick_table.h MINOR: stick-table: Add "server_name" new data type. 2019-06-05 08:33:35 +02:00
stream.h MEDIUM: stream: Make the unique_id member of struct stream a struct ist 2020-03-05 20:21:58 +01:00
stream_interface.h MEDIUM: stream-int: introduce a new state SI_ST_RDY 2019-06-06 16:36:19 +02:00
task.h MINOR: task: permanently flag tasklets waking themselves up 2020-01-31 17:45:10 +01:00
template.h [CLEANUP] included common/version.h everywhere 2006-06-29 18:54:54 +02:00
trace.h MINOR: trace: change the detail_level to per-source verbosity 2019-08-29 17:11:25 +02:00
vars.h MINOR: threads: Use __decl_hathreads to declare locks 2017-11-13 11:38:17 +01:00