summaryrefslogtreecommitdiff
path: root/res/snmp/agent.c
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-03-30 17:10:11 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-03-30 17:10:11 +0000
commit48864ab877d4e9038f3f8c0e119ab7e02c07523c (patch)
tree56636b4d708638cdb380dc76672be39341eec1f9 /res/snmp/agent.c
parent6d2fbc0b909d9802f67345630cb967311d72eb1c (diff)
do not export the tzlock and the list head, and introduce a new method,
ast_walk_indications(), to walk through the list of indications. The new method returns an unlocked record, which is no different from the behaviour of other existing methods in indications.c (i.e. they all need to be fixed, with refcounts or some similar method). Note that ast_walk_indications() uses the pointer argument only as a search key, so its implementation is completely safe. In turn, this change allows the removal of AST_MUTEX_DEFINE_EXPORTED. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16532 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/snmp/agent.c')
-rw-r--r--res/snmp/agent.c22
1 files changed, 5 insertions, 17 deletions
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;