diff options
author | Joshua Colp <jcolp@digium.com> | 2016-07-10 21:08:28 -0300 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2016-07-12 05:00:16 -0500 |
commit | 4ad333bb0e365b8a2795756225794c9d0b09e05c (patch) | |
tree | bf6ee35422453a71d469bc803271331aef711b64 /res | |
parent | 44f16af7cc9a6bc5203106a81b595997cb31c4fd (diff) |
func_odbc: Fix connection deadlock.
The func_odbc module was modified to ensure that the
previous behavior of using a single database connection
was maintained. This was done by getting a single database
connection and holding on to it. With the new multiple
connection support in res_odbc this will actually starve
every other thread from getting access to the database as
it also maintains the previous behavior of having only
a single database connection.
This change disables the func_odbc specific behavior if
the res_odbc module is running with only a single database
connection active. The connection is only kept for the
duration of the request.
ASTERISK-26177 #close
Change-Id: I9bdbd8a300fb3233877735ad3fd07bce38115b7f
Diffstat (limited to 'res')
-rw-r--r-- | res/res_odbc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c index a89c95492..bd64b9fef 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -744,6 +744,22 @@ static int aoro2_class_cb(void *obj, void *arg, int flags) return 0; } +unsigned int ast_odbc_get_max_connections(const char *name) +{ + struct odbc_class *class; + unsigned int max_connections; + + class = ao2_callback(class_container, 0, aoro2_class_cb, (char *) name); + if (!class) { + return 0; + } + + max_connections = class->maxconnections; + ao2_ref(class, -1); + + return max_connections; +} + /* * \brief Determine if the connection has died. * |