[asterisk-commits] branch bweschke/bug_6047 - r8451 in
/team/bweschke/bug_6047: ./ apps/ channel...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Jan 22 16:46:59 MST 2006
Author: bweschke
Date: Sun Jan 22 17:46:56 2006
New Revision: 8451
URL: http://svn.digium.com/view/asterisk?rev=8451&view=rev
Log:
More SVNMerge work
Modified:
team/bweschke/bug_6047/ (props changed)
team/bweschke/bug_6047/apps/app_queue.c
team/bweschke/bug_6047/channel.c
team/bweschke/bug_6047/channels/chan_sip.c
team/bweschke/bug_6047/include/asterisk/astosp.h
team/bweschke/bug_6047/res/res_osp.c
Propchange: team/bweschke/bug_6047/
------------------------------------------------------------------------------
--- svnmerge-blocked (original)
+++ svnmerge-blocked Sun Jan 22 17:46:56 2006
@@ -1,1 +1,1 @@
-/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8394,8412,8418
+/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8394,8412,8418,8445
Propchange: team/bweschke/bug_6047/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jan 22 17:46:56 2006
@@ -1,1 +1,1 @@
-/trunk:1-8433
+/trunk:1-8450
Modified: team/bweschke/bug_6047/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/apps/app_queue.c?rev=8451&r1=8450&r2=8451&view=diff
==============================================================================
--- team/bweschke/bug_6047/apps/app_queue.c (original)
+++ team/bweschke/bug_6047/apps/app_queue.c Sun Jan 22 17:46:56 2006
@@ -367,11 +367,10 @@
struct member *members; /*!< Head of the list of members */
struct queue_ent *head; /*!< Head of the list of callers */
- struct ast_call_queue *next; /*!< Next call queue */
+ AST_LIST_ENTRY(ast_call_queue) list; /*!< Next call queue */
};
-static struct ast_call_queue *queues = NULL;
-AST_MUTEX_DEFINE_STATIC(qlock);
+static AST_LIST_HEAD_STATIC(queues, ast_call_queue);
static int set_member_paused(char *queuename, char *interface, int paused);
@@ -481,8 +480,8 @@
}
if (option_debug)
ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
- ast_mutex_lock(&qlock);
- for (q = queues; q; q = q->next) {
+ AST_LIST_LOCK(&queues);
+ AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
cur = q->members;
while(cur) {
@@ -508,7 +507,7 @@
}
ast_mutex_unlock(&q->lock);
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
free(sc);
return NULL;
}
@@ -788,6 +787,30 @@
}
}
+static void free_members(struct ast_call_queue *q, int all)
+{
+ /* Free non-dynamic members */
+ struct member *curm, *next, *prev = NULL;
+
+ for (curm = q->members; curm; curm = next) {
+ next = curm->next;
+ if (all || !curm->dynamic) {
+ if (prev)
+ prev->next = next;
+ else
+ q->members = next;
+ free(curm);
+ } else
+ prev = curm;
+ }
+}
+
+static void destroy_queue(struct ast_call_queue *q)
+{
+ free_members(q, 1);
+ ast_mutex_destroy(&q->lock);
+ free(q);
+}
/*!\brief Reload a single queue via realtime.
\return Return the queue, or NULL if it doesn't exist.
@@ -795,18 +818,17 @@
static struct ast_call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
{
struct ast_variable *v;
- struct ast_call_queue *q, *prev_q = NULL;
+ struct ast_call_queue *q;
struct member *m, *prev_m, *next_m;
char *interface;
char *tmp, *tmp_name;
char tmpbuf[64]; /* Must be longer than the longest queue param name. */
/* Find the queue in the in-core list (we will create a new one if not found). */
- for (q = queues; q; q = q->next) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (!strcasecmp(q->name, queuename)) {
break;
}
- prev_q = q;
}
/* Static queues override realtime. */
@@ -838,13 +860,9 @@
/* Delete if unused (else will be deleted when last caller leaves). */
if (!q->count) {
/* Delete. */
- if (!prev_q) {
- queues = q->next;
- } else {
- prev_q->next = q->next;
- }
+ AST_LIST_REMOVE(&queues, q, list);
ast_mutex_unlock(&q->lock);
- free(q);
+ destroy_queue(q);
} else
ast_mutex_unlock(&q->lock);
}
@@ -858,8 +876,7 @@
ast_mutex_lock(&q->lock);
clear_queue(q);
q->realtime = 1;
- q->next = queues;
- queues = q;
+ AST_LIST_INSERT_HEAD(&queues, q, list);
}
init_queue(q); /* Ensure defaults for all parameters not set explicitly. */
@@ -923,13 +940,13 @@
struct ast_call_queue *q;
/* Find the queue in the in-core list first. */
- ast_mutex_lock(&qlock);
- for (q = queues; q; q = q->next) {
+ AST_LIST_LOCK(&queues);
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (!strcasecmp(q->name, queuename)) {
break;
}
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
if (!q) {
/*! \note Load from realtime before taking the global qlock, to avoid blocking all
@@ -950,7 +967,7 @@
}
}
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
q = find_queue_by_name_rt(queuename, queue_vars, member_config);
if (member_config)
@@ -958,7 +975,7 @@
if (queue_vars)
ast_variables_destroy(queue_vars);
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
}
return q;
}
@@ -976,7 +993,7 @@
if (!q)
return res;
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
ast_mutex_lock(&q->lock);
/* This is our one */
@@ -1025,50 +1042,8 @@
#endif
}
ast_mutex_unlock(&q->lock);
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
return res;
-}
-
-static void free_members(struct ast_call_queue *q, int all)
-{
- /* Free non-dynamic members */
- struct member *curm, *next, *prev;
-
- curm = q->members;
- prev = NULL;
- while(curm) {
- next = curm->next;
- if (all || !curm->dynamic) {
- if (prev)
- prev->next = next;
- else
- q->members = next;
- free(curm);
- } else
- prev = curm;
- curm = next;
- }
-}
-
-static void destroy_queue(struct ast_call_queue *q)
-{
- struct ast_call_queue *cur, *prev = NULL;
-
- ast_mutex_lock(&qlock);
- for (cur = queues; cur; cur = cur->next) {
- if (cur == q) {
- if (prev)
- prev->next = cur->next;
- else
- queues = cur->next;
- } else {
- prev = cur;
- }
- }
- ast_mutex_unlock(&qlock);
- free_members(q, 1);
- ast_mutex_destroy(&q->lock);
- free(q);
}
static int play_file(struct ast_channel *chan, char *filename)
@@ -1278,6 +1253,9 @@
ast_mutex_unlock(&q->lock);
if (q->dead && !q->count) {
/* It's dead and nobody is in it, so kill it */
+ AST_LIST_LOCK(&queues);
+ AST_LIST_REMOVE(&queues, q, list);
+ AST_LIST_UNLOCK(&queues);
destroy_queue(q);
}
}
@@ -1352,7 +1330,7 @@
/* &qlock and &rq->lock already set by try_calling()
* to solve deadlock */
- for (q = queues; q; q = q->next) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (q == rq) /* don't check myself, could deadlock */
continue;
ast_mutex_lock(&q->lock);
@@ -2113,7 +2091,7 @@
/* Hold the lock while we setup the outgoing calls */
if (use_weight)
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
ast_mutex_lock(&qe->parent->lock);
if (option_debug)
ast_log(LOG_DEBUG, "%s is trying to call a queue member.\n",
@@ -2129,7 +2107,7 @@
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
ast_mutex_unlock(&qe->parent->lock);
if (use_weight)
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
goto out;
}
tmp->stillgoing = -1;
@@ -2176,7 +2154,7 @@
ring_one(qe, outgoing, &numbusies);
ast_mutex_unlock(&qe->parent->lock);
if (use_weight)
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT));
ast_mutex_lock(&qe->parent->lock);
if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) {
@@ -2431,8 +2409,8 @@
struct member *last_member, *look;
int res = RES_NOSUCHQUEUE;
- ast_mutex_lock(&qlock);
- for (q = queues ; q ; q = q->next) {
+ AST_LIST_LOCK(&queues);
+ AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
if (!strcmp(q->name, queuename)) {
if ((last_member = interface_exists(q, interface))) {
@@ -2466,7 +2444,7 @@
}
ast_mutex_unlock(&q->lock);
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
return res;
}
@@ -2480,7 +2458,7 @@
* short-circuits if the queue is already in memory. */
q = load_realtime_queue(queuename);
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
if (q) {
ast_mutex_lock(&q->lock);
@@ -2515,7 +2493,7 @@
}
ast_mutex_unlock(&q->lock);
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
return res;
}
@@ -2530,8 +2508,8 @@
if (ast_strlen_zero(queuename))
ast_queue_log("NONE", "NONE", interface, (paused ? "PAUSEALL" : "UNPAUSEALL"), "%s", "");
- ast_mutex_lock(&qlock);
- for (q = queues ; q ; q = q->next) {
+ AST_LIST_LOCK(&queues);
+ AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) {
if ((mem = interface_exists(q, interface))) {
@@ -2554,7 +2532,7 @@
}
ast_mutex_unlock(&q->lock);
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
if (found)
return RESULT_SUCCESS;
@@ -2578,7 +2556,7 @@
struct ast_call_queue *cur_queue;
char queue_data[PM_MAX_LEN];
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
/* Each key in 'pm_family' is the name of a queue */
db_tree = ast_db_gettree(pm_family, NULL);
@@ -2586,13 +2564,11 @@
queue_name = entry->key + strlen(pm_family) + 2;
- cur_queue = queues;
- while (cur_queue) {
+ AST_LIST_TRAVERSE(&queues, cur_queue, list) {
ast_mutex_lock(&cur_queue->lock);
if (!strcmp(queue_name, cur_queue->name))
break;
ast_mutex_unlock(&cur_queue->lock);
- cur_queue = cur_queue->next;
}
if (!cur_queue) {
@@ -2645,7 +2621,7 @@
}
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
if (db_tree) {
ast_log(LOG_NOTICE, "Queue members successfully reloaded from database.\n");
ast_db_freetree(db_tree);
@@ -3185,17 +3161,17 @@
return buf;
}
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
/* Find the right queue */
- for (q = queues; q; q = q->next) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (!strcasecmp(q->name, data)) {
ast_mutex_lock(&q->lock);
break;
}
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
if (q) {
for (m = q->members; m; m = m->next) {
@@ -3228,17 +3204,17 @@
LOCAL_USER_ACF_ADD(u);
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
/* Find the right queue */
- for (q = queues; q; q = q->next) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (!strcasecmp(q->name, data)) {
ast_mutex_lock(&q->lock);
break;
}
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
if (q) {
int buflen = 0, count = 0;
@@ -3295,7 +3271,7 @@
static void reload_queues(void)
{
- struct ast_call_queue *q, *ql, *qn;
+ struct ast_call_queue *q;
struct ast_config *cfg;
char *cat, *tmp;
struct ast_variable *var;
@@ -3311,13 +3287,11 @@
return;
}
memset(interface, 0, sizeof(interface));
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
use_weight=0;
/* Mark all queues as dead for the moment */
- q = queues;
- while(q) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
q->dead = 1;
- q = q->next;
}
/* Chug through config file */
cat = ast_category_browse(cfg, NULL);
@@ -3329,11 +3303,9 @@
queue_persistent_members = ast_true(general_val);
} else { /* Define queue */
/* Look for an existing one */
- q = queues;
- while(q) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (!strcmp(q->name, cat))
break;
- q = q->next;
}
if (!q) {
/* Make one then */
@@ -3383,38 +3355,29 @@
}
var = var->next;
}
- if (!new)
+ if (new) {
+ AST_LIST_INSERT_HEAD(&queues, q, list);
+ } else
ast_mutex_unlock(&q->lock);
- if (new) {
- q->next = queues;
- queues = q;
- }
}
}
cat = ast_category_browse(cfg, cat);
}
ast_config_destroy(cfg);
- q = queues;
- ql = NULL;
- while(q) {
- qn = q->next;
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&queues, q, list) {
if (q->dead) {
- if (ql)
- ql->next = q->next;
+ AST_LIST_REMOVE_CURRENT(&queues, list);
+ if (!q->count)
+ destroy_queue(q);
else
- queues = q->next;
- if (!q->count) {
- free(q);
- } else
- ast_log(LOG_WARNING, "XXX Leaking a little memory :( XXX\n");
+ ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n");
} else {
for (cur = q->members; cur; cur = cur->next)
cur->status = ast_device_state(cur->interface);
- ql = q;
- }
- q = qn;
- }
- ast_mutex_unlock(&qlock);
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ AST_LIST_UNLOCK(&queues);
}
static int __queues_show(int manager, int fd, int argc, char **argv, int queue_show)
@@ -3438,24 +3401,21 @@
if (queue_show)
load_realtime_queue(argv[2]);
- ast_mutex_lock(&qlock);
-
- q = queues;
- if (!q) {
- ast_mutex_unlock(&qlock);
+ AST_LIST_LOCK(&queues);
+ if (AST_LIST_EMPTY(&queues)) {
+ AST_LIST_UNLOCK(&queues);
if (queue_show)
ast_cli(fd, "No such queue: %s.%s",argv[2], term);
else
ast_cli(fd, "No queues.%s", term);
return RESULT_SUCCESS;
}
- while (q) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
if (queue_show) {
if (strcasecmp(q->name, argv[2]) != 0) {
ast_mutex_unlock(&q->lock);
- q = q->next;
- if (!q) {
+ if (!AST_LIST_NEXT(q, list)) {
ast_cli(fd, "No such queue: %s.%s",argv[2], term);
break;
}
@@ -3506,11 +3466,10 @@
ast_cli(fd, " No Callers%s", term);
ast_cli(fd, "%s", term);
ast_mutex_unlock(&q->lock);
- q = q->next;
if (queue_show)
break;
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
return RESULT_SUCCESS;
}
@@ -3531,8 +3490,8 @@
int which = 0;
int wordlen = strlen(word);
- ast_mutex_lock(&qlock);
- for (q = queues; q; q = q->next) {
+ AST_LIST_LOCK(&queues);
+ AST_LIST_TRAVERSE(&queues, q, list) {
if (!strncasecmp(word, q->name, wordlen)) {
if (++which > state) {
ret = strdup(q->name);
@@ -3540,7 +3499,7 @@
}
}
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
return ret;
}
@@ -3573,11 +3532,11 @@
astman_send_ack(s, m, "Queue status will follow");
time(&now);
- ast_mutex_lock(&qlock);
+ AST_LIST_LOCK(&queues);
if (!ast_strlen_zero(id)) {
snprintf(idText,256,"ActionID: %s\r\n",id);
}
- for (q = queues; q; q = q->next) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
/* List queue properties */
@@ -3636,7 +3595,7 @@
}
ast_mutex_unlock(&q->lock);
}
- ast_mutex_unlock(&qlock);
+ AST_LIST_UNLOCK(&queues);
ast_cli(s->fd,
"Event: QueueStatusComplete\r\n"
@@ -3889,8 +3848,8 @@
return complete_queue(line, word, pos, state);
}
- if (queues != NULL) {
- for (q = queues ; q ; q = q->next) {
+ if (!AST_LIST_EMPTY(&queues)) {
+ AST_LIST_TRAVERSE(&queues, q, list) {
ast_mutex_lock(&q->lock);
for (m = q->members ; m ; m = m->next) {
if (++which > state) {
Modified: team/bweschke/bug_6047/channel.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/channel.c?rev=8451&r1=8450&r2=8451&view=diff
==============================================================================
--- team/bweschke/bug_6047/channel.c (original)
+++ team/bweschke/bug_6047/channel.c Sun Jan 22 17:46:56 2006
@@ -3911,7 +3911,7 @@
}
tocopy = (f->samples > samples) ? samples : f->samples;
- bytestocopy = ast_codec_get_len(queue->format, samples);
+ bytestocopy = ast_codec_get_len(queue->format, tocopy);
memcpy(buf, f->data, bytestocopy);
samples -= tocopy;
buf += tocopy;
Modified: team/bweschke/bug_6047/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/channels/chan_sip.c?rev=8451&r1=8450&r2=8451&view=diff
==============================================================================
--- team/bweschke/bug_6047/channels/chan_sip.c (original)
+++ team/bweschke/bug_6047/channels/chan_sip.c Sun Jan 22 17:46:56 2006
@@ -469,7 +469,7 @@
/*! \brief Parameters to the transmit_invite function */
struct sip_invite_param {
const char *distinctive_ring; /*!< Distinctive ring header */
- char *osptoken; /*!< OSP token for this call */
+ const char *osptoken; /*!< OSP token for this call */
int addsipheaders; /*!< Add extra SIP headers */
const char *uri_options; /*!< URI options to add to the URI */
const char *vxml_url; /*!< VXML url for Cisco phones */
@@ -2002,7 +2002,7 @@
int res;
struct sip_pvt *p;
#ifdef OSP_SUPPORT
- char *osphandle = NULL;
+ const char *osphandle = NULL;
#endif
struct varshead *headp;
struct ast_var_t *current;
Modified: team/bweschke/bug_6047/include/asterisk/astosp.h
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/include/asterisk/astosp.h?rev=8451&r1=8450&r2=8451&view=diff
==============================================================================
--- team/bweschke/bug_6047/include/asterisk/astosp.h (original)
+++ team/bweschke/bug_6047/include/asterisk/astosp.h Sun Jan 22 17:46:56 2006
@@ -43,6 +43,6 @@
int ast_osp_terminate(int handle, int cause, time_t start, time_t duration);
-int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *timeout, char *callerid, struct in_addr addr, char *extension);
+int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *timeout, const char *callerid, struct in_addr addr, const char *extension);
#endif /* _ASTERISK_OSP_H */
Modified: team/bweschke/bug_6047/res/res_osp.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_6047/res/res_osp.c?rev=8451&r1=8450&r2=8451&view=diff
==============================================================================
--- team/bweschke/bug_6047/res/res_osp.c (original)
+++ team/bweschke/bug_6047/res/res_osp.c Sun Jan 22 17:46:56 2006
@@ -452,7 +452,7 @@
return retVal;
}
-int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *timelimit, char *callerid, struct in_addr addr, char *extension)
+int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *timelimit, const char *callerid, struct in_addr addr, const char *extension)
{
char tmp[256]="", *l, *n;
char iabuf[INET_ADDRSTRLEN];
More information about the asterisk-commits
mailing list