After seeing crashes related to channel variables, I went looking around at the

ways that channel variables are handled.  In general, they were not handled in
a thread-safe way.  The channel _must_ be locked when reading or writing from/to
the channel variable list.

What I have done to improve this situation is to make pbx_builtin_setvar_helper()
and friends lock the channel when doing their thing.  Asterisk API calls almost 
all lock the channel for you as necessary, but this family of functions did not.

(closes issue #10923, reported by atis)
(closes issue #11159, reported by 850t)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@88805 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2007-11-05 22:07:54 +00:00
parent ea00780d49
commit 34002d567b
2 changed files with 61 additions and 11 deletions

View File

@@ -764,13 +764,37 @@ struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con,
struct ast_ignorepat *ip);
struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
/*!
* \note Will lock the channel.
*/
int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size);
/*!
* \note Will lock the channel.
*/
const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
/*!
* \note Will lock the channel.
*/
void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);
/*!
* \note Will lock the channel.
*/
void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
/*!
* \note Will lock the channel.
*/
void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
void pbx_builtin_clear_globals(void);
/*!
* \note Will lock the channel.
*/
int pbx_builtin_setvar(struct ast_channel *chan, void *data);
void pbx_substitute_variables_helper(struct ast_channel *c,const char *cp1,char *cp2,int count);
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count);