Merged revisions 176592,176642 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r176592 | tilghman | 2009-02-17 12:49:20 -0600 (Tue, 17 Feb 2009) | 4 lines
  
  Add assertions in the quest to track down a refcount leak.
  (closes issue #14485)
   Reported by: davevg
........
  r176642 | tilghman | 2009-02-17 15:14:18 -0600 (Tue, 17 Feb 2009) | 8 lines
  
  Prior to masquerade, move the group definitions to the channel performing the
  masq, so that the group count lingers past the bridge.
  (closes issue #14275)
   Reported by: kowalma
   Patches: 
         20090216__bug14275.diff.txt uploaded by Corydon76 (license 14)
   Tested by: kowalma
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@176644 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2009-02-17 21:16:53 +00:00
parent de6aec7594
commit 75ff7a609d
2 changed files with 29 additions and 9 deletions

View File

@@ -106,8 +106,8 @@ struct local_pvt {
char exten[AST_MAX_EXTENSION]; /* Extension to call */ char exten[AST_MAX_EXTENSION]; /* Extension to call */
int reqformat; /* Requested format */ int reqformat; /* Requested format */
struct ast_jb_conf jb_conf; /*!< jitterbuffer configuration for this local channel */ struct ast_jb_conf jb_conf; /*!< jitterbuffer configuration for this local channel */
struct ast_channel *owner; /* Master Channel */ struct ast_channel *owner; /* Master Channel - Bridging happens here */
struct ast_channel *chan; /* Outbound channel */ struct ast_channel *chan; /* Outbound channel - PBX is run here */
struct ast_module_user *u_owner; /*! reference to keep the module loaded while in use */ struct ast_module_user *u_owner; /*! reference to keep the module loaded while in use */
struct ast_module_user *u_chan; /*! reference to keep the module loaded while in use */ struct ast_module_user *u_chan; /*! reference to keep the module loaded while in use */
AST_LIST_ENTRY(local_pvt) list; /* Next entity */ AST_LIST_ENTRY(local_pvt) list; /* Next entity */
@@ -303,6 +303,7 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
p->chan->audiohooks = p->owner->audiohooks; p->chan->audiohooks = p->owner->audiohooks;
p->owner->audiohooks = audiohooks_swapper; p->owner->audiohooks = audiohooks_swapper;
} }
ast_app_group_update(p->chan, p->owner);
ast_channel_masquerade(p->owner, p->chan->_bridge); ast_channel_masquerade(p->owner, p->chan->_bridge);
ast_set_flag(p, LOCAL_ALREADY_MASQED); ast_set_flag(p, LOCAL_ALREADY_MASQED);
} }

View File

@@ -99,9 +99,11 @@ static int null_hash_fn(const void *obj, const int flags)
static void odbc_obj_destructor(void *data) static void odbc_obj_destructor(void *data)
{ {
struct odbc_obj *obj = data; struct odbc_obj *obj = data;
struct odbc_class *class = obj->parent;
obj->parent = NULL;
odbc_obj_disconnect(obj); odbc_obj_disconnect(obj);
ast_mutex_destroy(&obj->lock); ast_mutex_destroy(&obj->lock);
ao2_ref(obj->parent, -1); ao2_ref(class, -1);
} }
static void destroy_table_cache(struct odbc_cache_tables *table) { static void destroy_table_cache(struct odbc_cache_tables *table) {
@@ -556,10 +558,11 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
while ((class = ao2_iterator_next(&aoi))) { while ((class = ao2_iterator_next(&aoi))) {
if (!strncasecmp(a->word, class->name, length) && ++which > a->n) { if (!strncasecmp(a->word, class->name, length) && ++which > a->n) {
ret = ast_strdup(class->name); ret = ast_strdup(class->name);
ao2_ref(class, -1);
break;
} }
ao2_ref(class, -1); ao2_ref(class, -1);
if (ret) {
break;
}
} }
if (!ret && !strncasecmp(a->word, "all", length) && ++which > a->n) { if (!ret && !strncasecmp(a->word, "all", length) && ++which > a->n) {
ret = ast_strdup("all"); ret = ast_strdup("all");
@@ -674,6 +677,8 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
if (!class) if (!class)
return NULL; return NULL;
ast_assert(ao2_ref(class, 0) > 1);
if (class->haspool) { if (class->haspool) {
/* Recycle connections before building another */ /* Recycle connections before building another */
aoi = ao2_iterator_init(class->obj_container, 0); aoi = ao2_iterator_init(class->obj_container, 0);
@@ -687,6 +692,10 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
ao2_ref(obj, -1); ao2_ref(obj, -1);
} }
if (obj) {
ast_assert(ao2_ref(obj, 0) > 1);
}
if (!obj && (class->count < class->limit)) { if (!obj && (class->count < class->limit)) {
class->count++; class->count++;
obj = ao2_alloc(sizeof(*obj), odbc_obj_destructor); obj = ao2_alloc(sizeof(*obj), odbc_obj_destructor);
@@ -694,12 +703,14 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
ao2_ref(class, -1); ao2_ref(class, -1);
return NULL; return NULL;
} }
ast_assert(ao2_ref(obj, 0) == 1);
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;
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);
ast_assert(ao2_ref(class, 0) > 0);
obj = NULL; obj = NULL;
} else { } else {
obj->used = 1; obj->used = 1;
@@ -721,12 +732,14 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
if (obj) { if (obj) {
/* Object is not constructed, so delete outstanding reference to class. */ /* Object is not constructed, so delete outstanding reference to class. */
ast_assert(ao2_ref(class, 0) > 1);
ao2_ref(class, -1); ao2_ref(class, -1);
class = NULL; class = NULL;
} else { } 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) {
ast_assert(ao2_ref(class, 0) > 1);
ao2_ref(class, -1); ao2_ref(class, -1);
return NULL; return NULL;
} }
@@ -739,6 +752,7 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
obj = NULL; obj = NULL;
} else { } else {
ao2_link(class->obj_container, obj); ao2_link(class->obj_container, obj);
ast_assert(ao2_ref(obj, 0) > 1);
} }
class = NULL; class = NULL;
} }
@@ -758,6 +772,9 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
#endif #endif
ast_assert(class == NULL); ast_assert(class == NULL);
if (obj) {
ast_assert(ao2_ref(obj, 0) > 1);
}
return obj; return obj;
} }
@@ -777,11 +794,13 @@ static odbc_status odbc_obj_disconnect(struct odbc_obj *obj)
res = SQLDisconnect(obj->con); res = SQLDisconnect(obj->con);
if (obj->parent) {
if (res == SQL_SUCCESS || res == SQL_SUCCESS_WITH_INFO) { if (res == SQL_SUCCESS || res == SQL_SUCCESS_WITH_INFO) {
ast_log(LOG_DEBUG, "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 { } else {
ast_log(LOG_DEBUG, "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) == SQL_SUCCESS)) { if ((res = SQLFreeHandle(SQL_HANDLE_DBC, obj->con) == SQL_SUCCESS)) {
obj->con = NULL; obj->con = NULL;