mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
This function used to hold the listener's lock as a way to stay safe against concurrent manipulations, but it turns out this is wrong. First, the lock is held during l->accept(), which itself might indirectly call listener_release(), which, if the listener is marked full, could result in __resume_listener() to be called and the lock being taken twice. In practice it doesn't happen right now because the listener's FULL state cannot change while we're doing this. Second, all the code does is now protected against concurrent accesses. It used not to be the case in the early days of threads : the frequency counters are thread-safe. The rate limiting doesn't require extreme precision. Only the nbconn check is not thread safe. Third, the parts called here will have to be called from different threads without holding this lock, and this becomes a bigger issue if we need to keep this one. This patch does 3 things which need to be addressed at once : 1) it moves the lock to the only 2 functions that were not protected since called form listener_accept() : - limit_listener() - listener_full() 2) it makes sure delete_listener() properly checks its state within the lock. 3) it updates the l->nbconn tracking to make sure that it is always properly reported and accounted for. There is a point of particular care around the situation where the listener's maxconn is reached because the listener has to be marked full before accepting the connection, then resumed if the connection finally gets dropped. It is not possible to perform this change without removing the lock due to the deadlock issue explained above. This patch almost doubles the accept rate in multi-thread on a shared port between 8 threads, and multiplies by 4 the connection rate on a tcp-request connection reject rule.
The HAProxy documentation has been split into a number of different files for ease of use. Please refer to the following files depending on what you're looking for : - INSTALL for instructions on how to build and install HAProxy - LICENSE for the project's license - CONTRIBUTING for the process to follow to submit contributions The more detailed documentation is located into the doc/ directory : - doc/intro.txt for a quick introduction on HAProxy - doc/configuration.txt for the configuration's reference manual - doc/lua.txt for the Lua's reference manual - doc/SPOE.txt for how to use the SPOE engine - doc/network-namespaces.txt for how to use network namespaces under Linux - doc/management.txt for the management guide - doc/regression-testing.txt for how to use the regression testing suite - doc/peers.txt for the peers protocol reference - doc/coding-style.txt for how to adopt HAProxy's coding style - doc/internals for developer-specific documentation (not all up to date)
Description
Languages
C
98.1%
Shell
0.8%
Makefile
0.5%
Lua
0.2%
Python
0.2%