]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix unnecessary periodic close/open in connection pools (#4161)
authorMasamichi Hosoda <trueroad@trueroad.jp>
Thu, 29 Jul 2021 10:57:09 +0000 (19:57 +0900)
committerGitHub <noreply@github.com>
Thu, 29 Jul 2021 10:57:09 +0000 (06:57 -0400)
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.

src/lib/server/pool.c

index 16d70519f43e0aa3e76ce938decd95b092d99fb7..a953d1803ee96c00fb80fa006dea20a8865e2676 100644 (file)
@@ -686,7 +686,14 @@ static int connection_check(fr_pool_t *pool, request_t *request)
                 *      delete all of them.
                 */
                spawn = 0;
-               /* leave extra alone from above */
+               /*
+                *      But if the pool size is already "min", we
+                *      don't delete them.
+                */
+               if ((pool->state.num + pool->state.pending) == pool->min) {
+                       extra = 0;
+               }
+               /* Otherwise, leave extra alone from above */
 
        /*
         *      min < num < max