From af44a1b17a6864b6772c7384dca8552b8b7dc0ad Mon Sep 17 00:00:00 2001 From: russell Date: Mon, 5 Nov 2007 22:07:54 +0000 Subject: 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: http://svn.digium.com/svn/asterisk/branches/1.4@88805 f38db490-d61c-443f-a65b-d21fe96a405b --- include/asterisk/pbx.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/asterisk/pbx.h') diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index c558289c7..699aa5082 100644 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -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); -- cgit v1.2.3