mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Fix reference counts of the class and add an assertion to the end.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@165541 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -699,15 +699,19 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
|
|||||||
ast_mutex_init(&obj->lock);
|
ast_mutex_init(&obj->lock);
|
||||||
/* obj inherits the outstanding reference to class */
|
/* obj inherits the outstanding reference to class */
|
||||||
obj->parent = class;
|
obj->parent = class;
|
||||||
|
class = NULL;
|
||||||
if (odbc_obj_connect(obj) == ODBC_FAIL) {
|
if (odbc_obj_connect(obj) == ODBC_FAIL) {
|
||||||
ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
|
ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
|
||||||
ao2_ref(obj, -1);
|
ao2_ref(obj, -1);
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
class->count--;
|
|
||||||
} else {
|
} else {
|
||||||
obj->used = 1;
|
obj->used = 1;
|
||||||
ao2_link(class->obj_container, obj);
|
ao2_link(class->obj_container, obj);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* Object is not constructed, so delete outstanding reference to class. */
|
||||||
|
ao2_ref(class, -1);
|
||||||
|
class = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Non-pooled connection: multiple modules can use the same connection. */
|
/* Non-pooled connection: multiple modules can use the same connection. */
|
||||||
@@ -717,7 +721,11 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
|
|||||||
break;
|
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 */
|
/* No entry: build one */
|
||||||
obj = ao2_alloc(sizeof(*obj), odbc_obj_destructor);
|
obj = ao2_alloc(sizeof(*obj), odbc_obj_destructor);
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
@@ -727,6 +735,7 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
|
|||||||
ast_mutex_init(&obj->lock);
|
ast_mutex_init(&obj->lock);
|
||||||
/* obj inherits the outstanding reference to class */
|
/* obj inherits the outstanding reference to class */
|
||||||
obj->parent = class;
|
obj->parent = class;
|
||||||
|
class = NULL;
|
||||||
if (odbc_obj_connect(obj) == ODBC_FAIL) {
|
if (odbc_obj_connect(obj) == ODBC_FAIL) {
|
||||||
ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
|
ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
|
||||||
ao2_ref(obj, -1);
|
ao2_ref(obj, -1);
|
||||||
@@ -749,8 +758,8 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
|
|||||||
obj->lineno = lineno;
|
obj->lineno = lineno;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
ast_assert(class == NULL);
|
||||||
|
|
||||||
ao2_ref(class, -1);
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user