mirror of
https://github.com/asterisk/asterisk.git
synced 2026-06-17 05:03:15 +00:00
Allow early exit from traverse (bug #3221)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
+8
-8
@@ -5731,7 +5731,7 @@ static int sip_show_inuse(int fd, int argc, char *argv[]) {
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_cli(fd, FORMAT, "Username", "incoming", "Limit","outgoing","Limit");
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&userl, do {
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&userl, 1, do {
|
||||
ASTOBJ_RDLOCK(iterator);
|
||||
if (iterator->incominglimit)
|
||||
snprintf(ilimits, sizeof(ilimits), "%d", iterator->incominglimit);
|
||||
@@ -5774,7 +5774,7 @@ static int sip_show_users(int fd, int argc, char *argv[])
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_cli(fd, FORMAT, "Username", "Secret", "Accountcode", "Def.Context", "ACL", "NAT");
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&userl, do {
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&userl, 1, do {
|
||||
ASTOBJ_RDLOCK(iterator);
|
||||
ast_cli(fd, FORMAT, iterator->name,
|
||||
iterator->secret,
|
||||
@@ -5805,7 +5805,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_cli(fd, FORMAT2, "Name/username", "Host", "Dyn", "Nat", "ACL", "Mask", "Port", "Status");
|
||||
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&peerl, do {
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&peerl, 1, do {
|
||||
char nm[20] = "";
|
||||
char status[20] = "";
|
||||
int print_line = -1;
|
||||
@@ -6029,7 +6029,7 @@ static int sip_show_registry(int fd, int argc, char *argv[])
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_cli(fd, FORMAT2, "Host", "Username", "Refresh", "State");
|
||||
ASTOBJ_CONTAINER_TRAVERSE(®l, do {
|
||||
ASTOBJ_CONTAINER_TRAVERSE(®l, 1, do {
|
||||
ASTOBJ_RDLOCK(iterator);
|
||||
snprintf(host, sizeof(host), "%s:%d", iterator->hostname, iterator->portno ? iterator->portno : DEFAULT_SIP_PORT);
|
||||
ast_cli(fd, FORMAT, host, iterator->username, iterator->refresh, regstate2str(iterator->regstate));
|
||||
@@ -8083,12 +8083,12 @@ restartsearch:
|
||||
time(&t);
|
||||
fastrestart = 0;
|
||||
curpeernum = 0;
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&peerl, do {
|
||||
peer = NULL;
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&peerl, !peer, do {
|
||||
if ((curpeernum > lastpeernum) && !ast_strlen_zero(iterator->mailbox) && ((t - iterator->lastmsgcheck) > global_mwitime)) {
|
||||
fastrestart = 1;
|
||||
lastpeernum = curpeernum;
|
||||
peer = ASTOBJ_REF(iterator);
|
||||
break;
|
||||
};
|
||||
curpeernum++;
|
||||
} while (0)
|
||||
@@ -9313,7 +9313,7 @@ static void prune_peers(void)
|
||||
/*--- sip_poke_all_peers: Send a poke to all known peers */
|
||||
static void sip_poke_all_peers(void)
|
||||
{
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&peerl, do {
|
||||
ASTOBJ_CONTAINER_TRAVERSE(&peerl, 1, do {
|
||||
ASTOBJ_WRLOCK(iterator);
|
||||
sip_poke_peer(iterator);
|
||||
ASTOBJ_UNLOCK(iterator);
|
||||
@@ -9324,7 +9324,7 @@ static void sip_poke_all_peers(void)
|
||||
/*--- sip_send_all_registers: Send all known registrations */
|
||||
static void sip_send_all_registers(void)
|
||||
{
|
||||
ASTOBJ_CONTAINER_TRAVERSE(®l, do {
|
||||
ASTOBJ_CONTAINER_TRAVERSE(®l, 1, do {
|
||||
ASTOBJ_WRLOCK(iterator);
|
||||
__sip_do_register(iterator);
|
||||
ASTOBJ_UNLOCK(iterator);
|
||||
|
||||
@@ -148,13 +148,13 @@ extern "C" {
|
||||
ast_mutex_destroy(&(container)->_lock); \
|
||||
} while(0)
|
||||
|
||||
#define ASTOBJ_CONTAINER_TRAVERSE(container,eval) \
|
||||
#define ASTOBJ_CONTAINER_TRAVERSE(container,continue,eval) \
|
||||
do { \
|
||||
typeof((container)->head) iterator; \
|
||||
typeof((container)->head) next; \
|
||||
ASTOBJ_CONTAINER_RDLOCK(container); \
|
||||
next = (container)->head; \
|
||||
while((iterator = next)) { \
|
||||
while((continue) && (iterator = next)) { \
|
||||
next = iterator->next[0]; \
|
||||
eval; \
|
||||
} \
|
||||
@@ -164,14 +164,12 @@ extern "C" {
|
||||
#define ASTOBJ_CONTAINER_FIND_FULL(container,data,field,hashfunc,hashoffset,comparefunc) \
|
||||
({ \
|
||||
typeof((container)->head) found = NULL; \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, do { \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \
|
||||
ASTOBJ_RDLOCK(iterator); \
|
||||
if (!(comparefunc(iterator->field, (data)))) { \
|
||||
found = ASTOBJ_REF(iterator); \
|
||||
} \
|
||||
ASTOBJ_UNLOCK(iterator); \
|
||||
if (found) \
|
||||
break; \
|
||||
} while (0)); \
|
||||
found; \
|
||||
})
|
||||
@@ -192,7 +190,7 @@ extern "C" {
|
||||
({ \
|
||||
typeof((container)->head) found = NULL; \
|
||||
typeof((container)->head) prev = NULL; \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, do { \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, !found, do { \
|
||||
ASTOBJ_RDLOCK(iterator); \
|
||||
if (!(comparefunc(iterator->field, (data)))) { \
|
||||
found = iterator; \
|
||||
@@ -204,8 +202,6 @@ extern "C" {
|
||||
ASTOBJ_CONTAINER_UNLOCK(container); \
|
||||
} \
|
||||
ASTOBJ_UNLOCK(iterator); \
|
||||
if (found) \
|
||||
break; \
|
||||
prev = iterator; \
|
||||
} while (0)); \
|
||||
found; \
|
||||
@@ -214,7 +210,7 @@ extern "C" {
|
||||
#define ASTOBJ_CONTAINER_PRUNE_MARKED(container,destructor) \
|
||||
do { \
|
||||
typeof((container)->head) prev = NULL; \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, do { \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { \
|
||||
ASTOBJ_RDLOCK(iterator); \
|
||||
if (iterator->objflags & ASTOBJ_FLAG_MARKED) { \
|
||||
ASTOBJ_CONTAINER_WRLOCK(container); \
|
||||
@@ -266,16 +262,16 @@ extern "C" {
|
||||
ASTOBJ_CONTAINER_LINK_FULL(container,newobj,(newobj)->name,name,ASTOBJ_DEFAULT_HASH,0,strcasecmp)
|
||||
|
||||
#define ASTOBJ_CONTAINER_MARKALL(container) \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container,ASTOBJ_MARK(iterator))
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_MARK(iterator))
|
||||
|
||||
#define ASTOBJ_CONTAINER_UNMARKALL(container) \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container,ASTOBJ_UNMARK(iterator))
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, 1, ASTOBJ_UNMARK(iterator))
|
||||
|
||||
#define ASTOBJ_DUMP(s,slen,obj) \
|
||||
snprintf((s),(slen),"name: %s\nobjflags: %d\nrefcount: %d\n\n", (obj)->name, (obj)->objflags, (obj)->refcount);
|
||||
|
||||
#define ASTOBJ_CONTAINER_DUMP(fd,s,slen,container) \
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container,do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0))
|
||||
ASTOBJ_CONTAINER_TRAVERSE(container, 1, do { ASTOBJ_DUMP(s,slen,iterator); ast_cli(fd, s); } while(0))
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user