[asterisk-commits] tilghman: branch 1.6.1 r165543 - in /branches/1.6.1: ./ res/res_odbc.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Dec 18 10:48:14 CST 2008
Author: tilghman
Date: Thu Dec 18 10:48:13 2008
New Revision: 165543
URL: http://svn.digium.com/view/asterisk?view=rev&rev=165543
Log:
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.
........
Modified:
branches/1.6.1/ (props changed)
branches/1.6.1/res/res_odbc.c
Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.1/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/res/res_odbc.c?view=diff&rev=165543&r1=165542&r2=165543
==============================================================================
--- branches/1.6.1/res/res_odbc.c (original)
+++ branches/1.6.1/res/res_odbc.c Thu Dec 18 10:48:13 2008
@@ -697,15 +697,19 @@
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 @@
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 @@
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 @@
obj->lineno = lineno;
}
#endif
-
- ao2_ref(class, -1);
+ ast_assert(class == NULL);
+
return obj;
}
More information about the asterisk-commits
mailing list