aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-18 16:48:13 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-18 16:48:13 +0000
commit8d0a07661362b000befbef3a10430294c32e402f (patch)
treed258e3acad450444c019470c886c2a80eefa0a37
parent968cc8fd8a8e53f0477e404f80af55d41912b652 (diff)
Merged revisions 165541 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r165541 | tilghman | 2008-12-18 10:36:48 -0600 (Thu, 18 Dec 2008) | 2 lines Fix reference counts of the class and add an assertion to the end. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@165543 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--res/res_odbc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 18c64c9a3..d58864da0 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -697,15 +697,19 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
ast_mutex_init(&obj->lock);
/* obj inherits the outstanding reference to class */
obj->parent = class;
+ class = NULL;
if (odbc_obj_connect(obj) == ODBC_FAIL) {
ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
ao2_ref(obj, -1);
obj = NULL;
- class->count--;
} else {
obj->used = 1;
ao2_link(class->obj_container, obj);
}
+ } else {
+ /* Object is not constructed, so delete outstanding reference to class. */
+ ao2_ref(class, -1);
+ class = NULL;
}
} else {
/* Non-pooled connection: multiple modules can use the same connection. */
@@ -715,7 +719,11 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
break;
}
- if (!obj) {
+ if (obj) {
+ /* Object is not constructed, so delete outstanding reference to class. */
+ ao2_ref(class, -1);
+ class = NULL;
+ } else {
/* No entry: build one */
obj = ao2_alloc(sizeof(*obj), odbc_obj_destructor);
if (!obj) {
@@ -725,6 +733,7 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
ast_mutex_init(&obj->lock);
/* obj inherits the outstanding reference to class */
obj->parent = class;
+ class = NULL;
if (odbc_obj_connect(obj) == ODBC_FAIL) {
ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
ao2_ref(obj, -1);
@@ -747,8 +756,8 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
obj->lineno = lineno;
}
#endif
+ ast_assert(class == NULL);
- ao2_ref(class, -1);
return obj;
}