Alan T. DeKok [Thu, 12 Aug 2021 14:41:02 +0000 (10:41 -0400)]
do fast-path checks for errors
the error message is the same, but the difference is do we error
out immediately, or later, after all of the rest of the dictionaries
have been loaded.
James Jones [Fri, 6 Aug 2021 16:41:52 +0000 (11:41 -0500)]
Use calloc(), not malloc() to allocate heap/lst elements from the (memory) heap (#4175)
malloc(), in the C standard and in the man page, is described as not
initializing the memory it allocates. A standard-conforming C compiler
could thus compile versions of the tests that fail fr_{heap, lst}_insert()
checks that keep an item from being inserted twice or into more than one
heap or lst with the same index displacement.
Fix connection pool with fewer connections than spare setting (#4174)
The number of connections in the connection pool was not increased
when it is less than the spare setting.
In v4.0.x, unlike v3.0.x, `pool->max_pending` is a configurable value,
with a default value of zero.
Therefore, in the default setting, the conditional expression
`pool->state.pending >= pool->max_pending`
always is true and the number of connections is not increased.
This commit fixes it by using `pool->pending_window`
instead of `pool->max_pending`.
Alan T. DeKok [Thu, 5 Aug 2021 19:00:01 +0000 (15:00 -0400)]
allocate from the request, which is thread-safe. Helps with #3188
The "check" item is taken from the "huntgroups" file. It's in
a statically allocated list which doesn't change, and shouldn't
change during run-time. Allocating memory in its context is
not thread-safe, and can cause issues
James Jones [Thu, 5 Aug 2021 14:44:18 +0000 (09:44 -0500)]
Lst (#4169)
* Add leftmost skeleton tree API as a choice for priority queues
Relevant paper: "Stronger Quickheaps", Gonzalo Navarro, Rodrigo
Paredes, Patricio Poblete, and Peter Sanders, International
Journal of Foundations of Computer Science, November 2011.
Terry Burton [Tue, 3 Aug 2021 21:16:46 +0000 (22:16 +0100)]
MySQL sqlippool SP: Run as invoker, not definer; close transaction on error (#4171)
In MariaDB/MySQL, stored procedures default to running in the context of
the definer rather than the invoker.
This is a problem in a streaming replication scenario since the definer
is often the root user who has the "super" power to write to a read-only
database (unless super-read-only is enabled, which is not available for
MariaDB), thus breaking the replication timeline.
Additionally, exiting an SP does not finalise any running transaction.
If an exception is raised within the SP (e.g. due to the database being
read-only) we must handle this and finalise the transaction, otherwise
subsequent calls to "SET TRANSACTION ISOLATION LEVEL READ COMMITTED"
will fail ad nauseam until the connection is finally closed.
Fix unnecessary periodic close/open in connection pools (#4161)
When "min" and "max" values of the connection pool setting were the same,
periodic connection closing and opening occurred.
It was different from the closing caused
"uses", "lifetime", and "idle_timeout" settings.
"spare" setting is not helpful since it is capped to zero
by "min" and "max" are the same.
The behavior of the issue is as follows.
When the number of connections was "max" and there was an idol connection,
it was closed without checking "min".
Then, the number of connections dropped below "min" due to the close.
Therefore, a new connection was opened immediately
and the number of connections reached "max"
since "min" and "max" were the same.
These occurred repeatedly.
So periodic close/open happened.
This commit fixes the issue
by adding the "min" check to prevent unnecessary closing connections.
fr_pool_connection_release() recorded connection's last_reserved time
instead of last_released.
Since the last_released time of the connection was not updated,
the starting point of the idle_timeout was
always the connection opened time instead of the connection released time.
connection_check() in pool.c did not work
if more than 1 second has passed since the start of radiusd.
This commit makes the function works
as long as more than 1 second has passed since the last time it did work
by fixing a comparison operator.
make coccinelle.help - Print this
make coccinelle.clean - Clean up the build/coccinelle
make coccinelle.diff - Print diffs for files which would be changed by coccinelle.patch
make coccinelle.patch - Apply Coccinelle patches to all source files in the tree.