diff options
author | zuul <zuul@gerrit.asterisk.org> | 2016-07-12 15:28:26 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2016-07-12 15:28:26 -0500 |
commit | f3b7339260895d2aba2a2413917f85bf03ee19ea (patch) | |
tree | 42e665e8465943652f5375ee8aac71bc61954e95 /funcs | |
parent | 5ee205d8bb0dfbae5be89661aa3a787fbdf9986b (diff) | |
parent | 17efed6cf77d936c8e007c5d6afcd37acdc5b880 (diff) |
Merge "func_odbc: Fix connection deadlock." into 13
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_odbc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index b067f968a..e2ca7c823 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -388,9 +388,25 @@ static struct odbc_obj *get_odbc_obj(const char *dsn_name, struct dsn **dsn) static inline void release_obj_or_dsn(struct odbc_obj **obj, struct dsn **dsn) { if (dsn && *dsn) { + /* If multiple connections are not enabled then the guarantee + * of a single connection already exists and holding on to the + * connection would prevent any other user from acquiring it + * indefinitely. + */ + if (ast_odbc_get_max_connections((*dsn)->name) < 2) { + ast_odbc_release_obj((*dsn)->connection); + (*dsn)->connection = NULL; + } ao2_unlock(*dsn); ao2_ref(*dsn, -1); *dsn = NULL; + /* Some callers may provide both an obj and dsn. To ensure that + * the connection is not released twice we set it to NULL here if + * present. + */ + if (obj) { + *obj = NULL; + } } else if (obj && *obj) { ast_odbc_release_obj(*obj); *obj = NULL; |