aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-11 00:20:38 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-08-11 00:20:38 +0000
commitceb6400c66f6b1fa646297507893349df2928c6b (patch)
tree15a730be58fad27f167c714ed7bc494b30cf4952
parentbcf19b1370228e7b58eade1fa86b34d8a1ab02ae (diff)
Deallocate database connection handle on disconnect, as we allocate another
one on connect. (closes issue #13271) Reported by: dveiga git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@137138 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--res/res_odbc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 29e302330..f87b9e2bd 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -482,16 +482,27 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
static odbc_status odbc_obj_disconnect(struct odbc_obj *obj)
{
int res;
+ SQLINTEGER err;
+ short int mlen;
+ unsigned char msg[200], stat[10];
+
ast_mutex_lock(&obj->lock);
res = SQLDisconnect(obj->con);
if (res == ODBC_SUCCESS) {
- ast_log(LOG_WARNING, "res_odbc: disconnected %d from %s [%s]\n", res, obj->parent->name, obj->parent->dsn);
+ ast_log(LOG_DEBUG, "Disconnected %d from %s [%s]\n", res, obj->parent->name, obj->parent->dsn);
} else {
- ast_log(LOG_WARNING, "res_odbc: %s [%s] already disconnected\n",
- obj->parent->name, obj->parent->dsn);
+ ast_log(LOG_DEBUG, "res_odbc: %s [%s] already disconnected\n", obj->parent->name, obj->parent->dsn);
}
+
+ if ((res = SQLFreeHandle(SQL_HANDLE_DBC, obj->con) == ODBC_SUCCESS)) {
+ ast_log(LOG_DEBUG, "Database handle deallocated\n");
+ } else {
+ SQLGetDiagRec(SQL_HANDLE_DBC, obj->con, 1, stat, &err, msg, 100, &mlen);
+ ast_log(LOG_WARNING, "Unable to deallocate database handle? %d errno=%d %s\n", res, (int)err, msg);
+ }
+
obj->up = 0;
ast_mutex_unlock(&obj->lock);
return ODBC_SUCCESS;