[asterisk-commits] russell: branch 1.4 r63448 -
/branches/1.4/res/res_features.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue May 8 09:53:10 MST 2007
Author: russell
Date: Tue May 8 11:53:09 2007
New Revision: 63448
URL: http://svn.digium.com/view/asterisk?view=rev&rev=63448
Log:
I mixed up the use of the find_feature() function, so I renamed it
find_dynamic_feature, and changed the code to use the correct lock when
using it.
Modified:
branches/1.4/res/res_features.c
Modified: branches/1.4/res/res_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/res/res_features.c?view=diff&rev=63448&r1=63447&r2=63448
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Tue May 8 11:53:09 2007
@@ -932,7 +932,7 @@
}
/*! \brief find a feature by name */
-static struct ast_call_feature *find_feature(const char *name)
+static struct ast_call_feature *find_dynamic_feature(const char *name)
{
struct ast_call_feature *tmp;
@@ -1025,13 +1025,16 @@
static int remap_feature(const char *name, const char *value)
{
- int res = -1;
- struct ast_call_feature *feature;
+ int x, res = -1;
ast_rwlock_wrlock(&features_lock);
- if ((feature = find_feature(name))) {
- ast_copy_string(feature->exten, value, sizeof(feature->exten));
+ for (x = 0; x < FEATURES_COUNT; x++) {
+ if (strcasecmp(builtin_features[x].sname, name))
+ continue;
+
+ ast_copy_string(builtin_features[x].exten, value, sizeof(builtin_features[x].exten));
res = 0;
+ break;
}
ast_rwlock_unlock(&features_lock);
@@ -1076,23 +1079,21 @@
tmp = ast_strdupa(dynamic_features);
while ((tok = strsep(&tmp, "#"))) {
- ast_rwlock_rdlock(&features_lock);
- if (!(feature = find_feature(tok))) {
- ast_rwlock_unlock(&features_lock);
+ AST_LIST_LOCK(&feature_list);
+ if (!(feature = find_dynamic_feature(tok)))
continue;
- }
/* Feature is up for consideration */
if (!strcmp(feature->exten, code)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 " Feature Found: %s exten: %s\n",feature->sname, tok);
res = feature->operation(chan, peer, config, code, sense);
- ast_rwlock_unlock(&features_lock);
+ AST_LIST_UNLOCK(&feature_list);
break;
} else if (!strncmp(feature->exten, code, strlen(code)))
res = FEATURE_RETURN_STOREDIGITS;
- ast_rwlock_unlock(&features_lock);
+ AST_LIST_UNLOCK(&feature_list);
}
return res;
@@ -1127,14 +1128,14 @@
/* while we have a feature */
while ((tok = strsep(&tmp, "#"))) {
- ast_rwlock_rdlock(&features_lock);
- if ((feature = find_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
+ AST_LIST_LOCK(&feature_list);
+ if ((feature = find_dynamic_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
if (ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLER))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
if (ast_test_flag(feature, AST_FEATURE_FLAG_BYCALLEE))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
}
- ast_rwlock_unlock(&features_lock);
+ AST_LIST_UNLOCK(&feature_list);
}
}
}
@@ -2299,10 +2300,13 @@
continue;
}
- if ((feature = find_feature(var->name))) {
+ AST_LIST_LOCK(&feature_list);
+ if ((feature = find_dynamic_feature(var->name))) {
+ AST_LIST_UNLOCK(&feature_list);
ast_log(LOG_WARNING, "Dynamic Feature '%s' specified more than once!\n", var->name);
continue;
}
+ AST_LIST_UNLOCK(&feature_list);
if (!(feature = ast_calloc(1, sizeof(*feature))))
continue;
More information about the asterisk-commits
mailing list