mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-17 10:11:53 +00:00
Switch to a scoped lock to avoid missing unlocks in failure returns.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@402769 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -7595,8 +7595,7 @@ struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan)
|
|||||||
RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
|
RAII_VAR(struct varshead *, ret, NULL, ao2_cleanup);
|
||||||
RAII_VAR(struct ast_str *, tmp, NULL, ast_free);
|
RAII_VAR(struct ast_str *, tmp, NULL, ast_free);
|
||||||
struct manager_channel_variable *mcv;
|
struct manager_channel_variable *mcv;
|
||||||
|
SCOPED_LOCK(lock, &channelvars, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
|
||||||
AST_RWLIST_RDLOCK(&channelvars);
|
|
||||||
|
|
||||||
if (AST_LIST_EMPTY(&channelvars)) {
|
if (AST_LIST_EMPTY(&channelvars)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -7626,13 +7625,11 @@ struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan)
|
|||||||
|
|
||||||
var = ast_var_assign(mcv->name, val ? val : "");
|
var = ast_var_assign(mcv->name, val ? val : "");
|
||||||
if (!var) {
|
if (!var) {
|
||||||
AST_RWLIST_UNLOCK(&channelvars);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST_RWLIST_INSERT_TAIL(ret, var, entries);
|
AST_RWLIST_INSERT_TAIL(ret, var, entries);
|
||||||
}
|
}
|
||||||
AST_RWLIST_UNLOCK(&channelvars);
|
|
||||||
|
|
||||||
ao2_ref(ret, +1);
|
ao2_ref(ret, +1);
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user