aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_indications.c16
-rw-r--r--res/snmp/agent.c22
2 files changed, 10 insertions, 28 deletions
diff --git a/res/res_indications.c b/res/res_indications.c
index 1188b0586..cb3a766ec 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -149,26 +149,20 @@ static int handle_remove_indication(int fd, int argc, char *argv[])
*/
static int handle_show_indications(int fd, int argc, char *argv[])
{
- struct tone_zone *tz;
+ struct tone_zone *tz = NULL;
char buf[256];
int found_country = 0;
- if (ast_mutex_lock(&tzlock)) {
- ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
- return 0;
- }
if (argc == 2) {
/* no arguments, show a list of countries */
ast_cli(fd,"Country Alias Description\n"
"===========================\n");
- for (tz=tone_zones; tz; tz=tz->next) {
+ while ( (tz = ast_walk_indications(tz) ) )
ast_cli(fd,"%-7.7s %-7.7s %s\n", tz->country, tz->alias, tz->description);
- }
- ast_mutex_unlock(&tzlock);
return 0;
}
/* there was a request for specific country(ies), lets humor them */
- for (tz=tone_zones; tz; tz=tz->next) {
+ while ( (tz = ast_walk_indications(tz) ) ) {
int i,j;
for (i=2; i<argc; i++) {
if (strcasecmp(tz->country,argv[i])==0 &&
@@ -183,7 +177,8 @@ static int handle_show_indications(int fd, int argc, char *argv[])
for (i=0; i<tz->nrringcadence; i++) {
j += snprintf(buf+j,sizeof(buf)-j,"%d,",tz->ringcadence[i]);
}
- if (tz->nrringcadence) j--;
+ if (tz->nrringcadence)
+ j--;
ast_copy_string(buf+j,"\n",sizeof(buf)-j);
ast_cli(fd,buf);
for (ts=tz->tones; ts; ts=ts->next)
@@ -194,7 +189,6 @@ static int handle_show_indications(int fd, int argc, char *argv[])
}
if (!found_country)
ast_cli(fd,"No countries matched your criteria.\n");
- ast_mutex_unlock(&tzlock);
return -1;
}
diff --git a/res/snmp/agent.c b/res/snmp/agent.c
index 740f5c10e..182601077 100644
--- a/res/snmp/agent.c
+++ b/res/snmp/agent.c
@@ -631,22 +631,16 @@ static u_char *ast_var_indications(struct variable *vp, oid *name, size_t *lengt
int exact, size_t *var_len, WriteMethod **write_method)
{
static unsigned long long_ret;
- struct tone_zone *tz;
+ struct tone_zone *tz = NULL;
if (header_generic(vp, name, length, exact, var_len, write_method))
return NULL;
switch (vp->magic) {
case ASTINDCOUNT:
- if (ast_mutex_lock(&tzlock)) {
- ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
- snmp_log(LOG_ERR, "Unable to lock tone_zones list in ast_var_indications\n");
- return NULL;
- }
long_ret = 0;
- for (tz = tone_zones; tz; tz = tz->next)
+ while ( (tz = ast_walk_indications(tz)) )
long_ret++;
- ast_mutex_unlock(&tzlock);
return (u_char *)&long_ret;
case ASTINDCURRENT:
@@ -667,21 +661,15 @@ static u_char *ast_var_indications_table(struct variable *vp, oid *name, size_t
int exact, size_t *var_len, WriteMethod **write_method)
{
static unsigned long long_ret;
- struct tone_zone *tz;
+ struct tone_zone *tz = NULL;
int i;
if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
return NULL;
- if (ast_mutex_lock(&tzlock)) {
- ast_log(LOG_WARNING, "Unable to lock tone_zones list\n");
- snmp_log(LOG_ERR, "Unable to lock tone_zones list in ast_var_indications_table\n");
- return NULL;
- }
i = name[*length - 1] - 1;
- for (tz = tone_zones; tz && i; tz = tz->next)
- i--;
- ast_mutex_unlock(&tzlock);
+ while ( (tz = ast_walk_indications(tz)) && i )
+ i--;
if (tz == NULL)
return NULL;