improve linked-list macros in two ways:

- the *_CURRENT macros no longer need the list head pointer argument
  - add AST_LIST_MOVE_CURRENT to encapsulate the remove/add operation when moving entries between lists


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89106 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2007-11-08 05:28:47 +00:00
parent 950528b638
commit edc78d6023
41 changed files with 166 additions and 183 deletions

View File

@@ -2598,7 +2598,7 @@ static void purge_sessions(int n_max)
AST_LIST_LOCK(&sessions);
AST_LIST_TRAVERSE_SAFE_BEGIN(&sessions, s, list) {
if (s->sessiontimeout && (now > s->sessiontimeout) && !s->inuse) {
AST_LIST_REMOVE_CURRENT(&sessions, list);
AST_LIST_REMOVE_CURRENT(list);
ast_atomic_fetchadd_int(&num_sessions, -1);
if (s->authenticated && (option_verbose > 1) && manager_displayconnects(s)) {
ast_verb(2, "HTTP Manager '%s' timed out from %s\n",
@@ -2609,7 +2609,7 @@ static void purge_sessions(int n_max)
break;
}
}
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&sessions);
}
@@ -2719,13 +2719,13 @@ int ast_manager_unregister(char *action)
AST_RWLIST_WRLOCK(&actions);
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&actions, cur, list) {
if (!strcasecmp(action, cur->action)) {
AST_RWLIST_REMOVE_CURRENT(&actions, list);
AST_RWLIST_REMOVE_CURRENT(list);
ast_free(cur);
ast_verb(2, "Manager unregistered action %s\n", action);
break;
}
}
AST_RWLIST_TRAVERSE_SAFE_END
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&actions);
return 0;
@@ -3476,7 +3476,7 @@ static int __init_manager(int reload)
continue;
}
/* We do not need to keep this user so take them out of the list */
AST_RWLIST_REMOVE_CURRENT(&users, list);
AST_RWLIST_REMOVE_CURRENT(list);
/* Free their memory now */
if (user->secret)
ast_free(user->secret);
@@ -3490,7 +3490,7 @@ static int __init_manager(int reload)
ast_free(user->write);
ast_free(user);
}
AST_RWLIST_TRAVERSE_SAFE_END
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&users);