]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_odbc: release threads from potential starvation.
authorJaco Kroon <jaco@uls.co.za>
Tue, 10 Dec 2024 19:47:49 +0000 (21:47 +0200)
committerJaco Kroon <jaco@uls.co.za>
Tue, 17 Dec 2024 15:10:26 +0000 (15:10 +0000)
commit9b45103bc815ccf74d1a4c3e1498bdfd4f8bbda8
tree0f452c260153e3232fed2400a4660904a9309f5a
parentd832aae1d7bb49cf0f4723028ea37c7c09afab78
res_odbc: release threads from potential starvation.

Whenever a slot is freed up due to a failed connection, wake up a waiter
before failing.

In the case of a dead connection there could be waiters, for example,
let's say two threads tries to acquire objects at the same time, with
one in the cached connections, one will acquire the dead connection, and
the other will enter into the wait state.  The thread with the dead
connection will clear up the dead connection, and then attempt a
re-acquire (at this point there cannot be cached connections else the
other thread would have received that and tried to clean up), as such,
at this point we're guaranteed that either there are no waiting threads,
or that the maxconnections - connection_cnt threads will attempt to
re-acquire connections, and then either succeed, using those
connections, or failing, and then signalling to release more waiters.

Also fix the pointer log for ODBC handle %p dead which would always
reflect NULL.

Signed-off-by: Jaco Kroon <jaco@uls.co.za>
res/res_odbc.c