]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: stick-table: Always decrement ref count before killing a session
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Jun 2024 12:45:24 +0000 (14:45 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Jun 2024 13:05:06 +0000 (15:05 +0200)
commitad946a704dc19b1a5aa51692ca7aafb5b015ba7c
tree49c4da97db665e72dc086de296e41cac99d07982
parent9357873641c5de29b169848fc1c808747818a1eb
MINOR: stick-table: Always decrement ref count before killing a session

Guarded functions to kill a sticky session, stksess_kill()
stksess_kill_if_expired(), may or may not decrement and test its reference
counter before really killing it. This depends on a parameter. If it is set
to non-zero value, the ref count is decremented and if it falls to zero, the
session is killed. Otherwise, if this parameter is equal to zero, the
session is killed, regardless the ref count value.

In the code, these functions are always called with a non-zero parameter and
the ref count is always decremented and tested. So, there is no reason to
still have a special case. Especially because it is not really easy to say
if it is supported or not. Does it mean it is possible to kill a sticky
session while it is still referenced somewhere ? probably not. So, does it
mean it is possible to kill a unreferenced session ? This case may be
problematic because the session is accessed outside of any lock and thus may
be released by another thread because it is unreferenced. Enlarging scope of
the lock to avoid any issue is possible but it is a bit of shame to do so
because there is no usage for now.

The best is to simplify the API and remove this case. Now, stksess_kill()
and stksess_kill_if_expired() functions always decrement and test the ref
count before killing a sticky session.
include/haproxy/session.h
include/haproxy/stick_table.h
include/haproxy/stream.h
src/stick_table.c