diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-03-30 17:10:11 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-03-30 17:10:11 +0000 |
commit | 70020a2853bd51930d36fd997fc71eedfe71eb6e (patch) | |
tree | 56636b4d708638cdb380dc76672be39341eec1f9 /res/snmp | |
parent | cd3c76f7f1e6a0655e035b8ab8d164109d31f92c (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: http://svn.digium.com/svn/asterisk/trunk@16532 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/snmp')
-rw-r--r-- | res/snmp/agent.c | 22 |
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; |