From: Russell Bryant Date: Tue, 28 Aug 2007 18:41:18 +0000 (+0000) Subject: Add proper channel locking around the uses of datastore_add and _find. There X-Git-Tag: 1.6.0-beta1~3^2~1598 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f4a2811b6f7033983cbd00c6f5cb4d4585e3146;p=thirdparty%2Fasterisk.git Add proper channel locking around the uses of datastore_add and _find. There are still more places in the tree that I have not yet changed if someone wants to go through and find the places they are used without the channel locked. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81262 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/funcs/func_enum.c b/funcs/func_enum.c index f3655be9eb..677698cfe9 100644 --- a/funcs/func_enum.c +++ b/funcs/func_enum.c @@ -201,7 +201,9 @@ static int enum_query_read(struct ast_channel *chan, const char *cmd, char *data datastore->data = erds; + ast_channel_lock(chan); ast_channel_datastore_add(chan, datastore); + ast_channel_unlock(chan); res = 0; @@ -246,7 +248,10 @@ static int enum_result_read(struct ast_channel *chan, const char *cmd, char *dat goto finish; } - if (!(datastore = ast_channel_datastore_find(chan, &enum_result_datastore_info, args.id))) { + ast_channel_lock(chan); + datastore = ast_channel_datastore_find(chan, &enum_result_datastore_info, args.id); + ast_channel_unlock(chan); + if (!datastore) { ast_log(LOG_WARNING, "No ENUM results found for query id!\n"); goto finish; } diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index e165104cce..169426c4ce 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -3934,7 +3934,9 @@ static int dundi_query_read(struct ast_channel *chan, const char *cmd, char *dat if (drds->num_results > 0) sort_results(drds->results, drds->num_results); + ast_channel_lock(chan); ast_channel_datastore_add(chan, datastore); + ast_channel_unlock(chan); ast_module_user_remove(u); @@ -3991,11 +3993,16 @@ static int dundi_result_read(struct ast_channel *chan, const char *cmd, char *da ast_log(LOG_ERROR, "A result number must be given to DUNDIRESULT!\n"); goto finish; } + + ast_channel_lock(chan); + datastore = ast_channel_datastore_find(chan, &dundi_result_datastore_info, args.id); + ast_channel_unlock(chan); - if (!(datastore = ast_channel_datastore_find(chan, &dundi_result_datastore_info, args.id))) { + if (!datastore) { ast_log(LOG_WARNING, "No DUNDi results found for query ID '%s'\n", args.id); goto finish; } + drds = datastore->data; if (!strcasecmp(args.resultnum, "getnum")) {