BUG/MEDIUM: fd/threads: ensure the fdcache_mask always reflects the cache contents
authorWilly Tarreau <w@1wt.eu>
Tue, 20 Mar 2018 18:06:52 +0000 (19:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Mar 2018 18:14:24 +0000 (19:14 +0100)
commit26fb5d8449f3b17317d2b7b5c54979f576d5f95b
treed2e14df2964b802f6afc414d76646e5f6ebb3a0a
parentcde05c85ef3da3c54b79d7ad3570d0e13ebd620c
BUG/MEDIUM: fd/threads: ensure the fdcache_mask always reflects the cache contents

Commit 4815c8c ("MAJOR: fd/threads: Make the fdcache mostly lockless.")
made the fd cache lockless, but after a few iterations, a subtle part was
lost, consisting in setting the bit on the fd_cache_mask immediately when
adding an event. Now it was done only when the cache started to process
events, but the problem it causes is that fd_cache_mask isn't reliable
anymore as an indicator of presence of events to be processed with no
delay outside of fd_process_cached_events(). This results in some spurious
delays when processing inter-thread wakeups between tasks. Just restoring
the flag when the event is added is enough to fix the problem.

Kudos to Christopher for spotting this one!

No backport is needed as this is only in the development version.
include/proto/fd.h