mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 08:40:16 +00:00
coding style cleanups on queue interface handling code that was committed for the last release
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@34160 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -472,8 +472,7 @@ static void *changethread(void *data)
|
|||||||
technology = ast_strdupa(sc->dev);
|
technology = ast_strdupa(sc->dev);
|
||||||
loc = strchr(technology, '/');
|
loc = strchr(technology, '/');
|
||||||
if (loc) {
|
if (loc) {
|
||||||
*loc = '\0';
|
*loc++ = '\0';
|
||||||
loc++;
|
|
||||||
} else {
|
} else {
|
||||||
free(sc);
|
free(sc);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -486,19 +485,27 @@ static void *changethread(void *data)
|
|||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&interfaces);
|
AST_LIST_UNLOCK(&interfaces);
|
||||||
|
|
||||||
if (curint) {
|
if (!curint) {
|
||||||
|
if (option_debug)
|
||||||
|
ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
|
||||||
|
free(sc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (option_debug)
|
if (option_debug)
|
||||||
ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
|
ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
|
||||||
ast_mutex_lock(&qlock);
|
ast_mutex_lock(&qlock);
|
||||||
for (q = queues; q; q = q->next) {
|
for (q = queues; q; q = q->next) {
|
||||||
ast_mutex_lock(&q->lock);
|
ast_mutex_lock(&q->lock);
|
||||||
cur = q->members;
|
for (cur = q->members; cur; cur = cur->next) {
|
||||||
while(cur) {
|
if (strcasecmp(sc->dev, cur->interface))
|
||||||
if (!strcasecmp(sc->dev, cur->interface)) {
|
continue;
|
||||||
|
|
||||||
if (cur->status != sc->state) {
|
if (cur->status != sc->state) {
|
||||||
cur->status = sc->state;
|
cur->status = sc->state;
|
||||||
if (!q->maskmemberstatus) {
|
if (q->maskmemberstatus)
|
||||||
|
continue;
|
||||||
|
|
||||||
manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
|
manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
|
||||||
"Queue: %s\r\n"
|
"Queue: %s\r\n"
|
||||||
"Location: %s\r\n"
|
"Location: %s\r\n"
|
||||||
@@ -512,17 +519,10 @@ static void *changethread(void *data)
|
|||||||
cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
|
cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cur = cur->next;
|
|
||||||
}
|
|
||||||
ast_mutex_unlock(&q->lock);
|
ast_mutex_unlock(&q->lock);
|
||||||
}
|
}
|
||||||
ast_mutex_unlock(&qlock);
|
ast_mutex_unlock(&qlock);
|
||||||
} else {
|
|
||||||
if (option_debug)
|
|
||||||
ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
|
|
||||||
}
|
|
||||||
free(sc);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,8 +534,9 @@ static int statechange_queue(const char *dev, int state, void *ign)
|
|||||||
pthread_t t;
|
pthread_t t;
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
|
|
||||||
sc = malloc(sizeof(struct statechange) + strlen(dev) + 1);
|
if (!(sc = malloc(sizeof(*sc) + strlen(dev) + 1)))
|
||||||
if (sc) {
|
return 0;
|
||||||
|
|
||||||
sc->state = state;
|
sc->state = state;
|
||||||
strcpy(sc->dev, dev);
|
strcpy(sc->dev, dev);
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
@@ -544,7 +545,7 @@ static int statechange_queue(const char *dev, int state, void *ign)
|
|||||||
ast_log(LOG_WARNING, "Failed to create update thread!\n");
|
ast_log(LOG_WARNING, "Failed to create update thread!\n");
|
||||||
free(sc);
|
free(sc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +621,7 @@ static void clear_queue(struct ast_call_queue *q)
|
|||||||
|
|
||||||
static int add_to_interfaces(char *interface)
|
static int add_to_interfaces(char *interface)
|
||||||
{
|
{
|
||||||
struct ast_member_interfaces *curint, *newint;
|
struct ast_member_interfaces *curint;
|
||||||
|
|
||||||
if (!interface)
|
if (!interface)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -631,15 +632,18 @@ static int add_to_interfaces(char *interface)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!curint) {
|
if (curint) {
|
||||||
|
AST_LIST_UNLOCK(&interfaces);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (option_debug)
|
if (option_debug)
|
||||||
ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
|
ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
|
||||||
|
|
||||||
if ((newint = malloc(sizeof(*newint)))) {
|
if ((curint = malloc(sizeof(*curint)))) {
|
||||||
memset(newint, 0, sizeof(*newint));
|
memset(curint, 0, sizeof(*curint));
|
||||||
ast_copy_string(newint->interface, interface, sizeof(newint->interface));
|
ast_copy_string(curint->interface, interface, sizeof(curint->interface));
|
||||||
AST_LIST_INSERT_HEAD(&interfaces, newint, list);
|
AST_LIST_INSERT_HEAD(&interfaces, curint, list);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&interfaces);
|
AST_LIST_UNLOCK(&interfaces);
|
||||||
|
|
||||||
@@ -658,13 +662,9 @@ static int interface_exists_global(char *interface)
|
|||||||
ast_mutex_lock(&qlock);
|
ast_mutex_lock(&qlock);
|
||||||
for (q = queues; q && !ret; q = q->next) {
|
for (q = queues; q && !ret; q = q->next) {
|
||||||
ast_mutex_lock(&q->lock);
|
ast_mutex_lock(&q->lock);
|
||||||
mem = q->members;
|
for (mem = q->members; mem && !ret; mem = mem->next) {
|
||||||
while(mem) {
|
if (!strcasecmp(interface, mem->interface))
|
||||||
if (!strcasecmp(interface, mem->interface)) {
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
|
||||||
}
|
|
||||||
mem = mem->next;
|
|
||||||
}
|
}
|
||||||
ast_mutex_unlock(&q->lock);
|
ast_mutex_unlock(&q->lock);
|
||||||
}
|
}
|
||||||
@@ -673,7 +673,6 @@ static int interface_exists_global(char *interface)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int remove_from_interfaces(char *interface)
|
static int remove_from_interfaces(char *interface)
|
||||||
{
|
{
|
||||||
struct ast_member_interfaces *curint;
|
struct ast_member_interfaces *curint;
|
||||||
@@ -683,12 +682,15 @@ static int remove_from_interfaces(char *interface)
|
|||||||
|
|
||||||
AST_LIST_LOCK(&interfaces);
|
AST_LIST_LOCK(&interfaces);
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
|
AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
|
||||||
if (!strcasecmp(curint->interface, interface) && !interface_exists_global(interface)) {
|
if (!strcasecmp(curint->interface, interface)) {
|
||||||
|
if (!interface_exists_global(interface)) {
|
||||||
if (option_debug)
|
if (option_debug)
|
||||||
ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
|
ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
|
||||||
AST_LIST_REMOVE_CURRENT(&interfaces, list);
|
AST_LIST_REMOVE_CURRENT(&interfaces, list);
|
||||||
free(curint);
|
free(curint);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
AST_LIST_TRAVERSE_SAFE_END;
|
||||||
AST_LIST_UNLOCK(&interfaces);
|
AST_LIST_UNLOCK(&interfaces);
|
||||||
@@ -701,14 +703,9 @@ static void clear_and_free_interfaces(void)
|
|||||||
struct ast_member_interfaces *curint;
|
struct ast_member_interfaces *curint;
|
||||||
|
|
||||||
AST_LIST_LOCK(&interfaces);
|
AST_LIST_LOCK(&interfaces);
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
|
while ((curint = AST_LIST_REMOVE_HEAD(&interfaces, list)))
|
||||||
AST_LIST_REMOVE_CURRENT(&interfaces, list);
|
|
||||||
free(curint);
|
free(curint);
|
||||||
}
|
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
|
||||||
AST_LIST_UNLOCK(&interfaces);
|
AST_LIST_UNLOCK(&interfaces);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Configure a queue parameter.
|
/*! \brief Configure a queue parameter.
|
||||||
|
|||||||
Reference in New Issue
Block a user