aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_meetme.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-03 20:38:13 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-03 20:38:13 +0000
commita0b795f0812a231bc7a0c097931f5cc8d51333d2 (patch)
tree2f5ac9dbc27e12f1fe4c415ab79132b90a09856d /apps/app_meetme.c
parent8d68ea3d42ef1bcecf2a8f23ab73e875cc529132 (diff)
set the DIALSTATUS variable to contain "INVALIDARGS" when the dial application
exits early because of invalid arguments instead of just leaving it empty. (issue #8975) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@53133 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_meetme.c')
-rw-r--r--apps/app_meetme.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 1efd4bbb4..8987de096 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -139,6 +139,7 @@ static struct ast_conference {
struct ast_conf_user *firstuser; /* Pointer to the first user struct */
struct ast_conf_user *lastuser; /* Pointer to the last user struct */
time_t start; /* Start time (s) */
+ int refcount;
int recording; /* recording status */
int isdynamic; /* Created on the fly? */
int locked; /* Is the conference locked? */
@@ -438,7 +439,7 @@ static void conf_play(struct ast_channel *chan, struct ast_conference *conf, int
ast_autoservice_stop(chan);
}
-static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin, int make, int dynamic)
+static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin, int make, int dynamic, int refcount)
{
struct ast_conference *cnf;
struct zt_confinfo ztc;
@@ -501,6 +502,8 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
ast_log(LOG_WARNING, "Out of memory\n");
}
cnfout:
+ if (cnf)
+ ast_atomic_fetchadd_int(&cnf->refcount, refcount);
ast_mutex_unlock(&conflock);
return cnf;
}
@@ -835,6 +838,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
if (!user) {
ast_log(LOG_ERROR, "Out of memory\n");
+ if (ast_atomic_dec_and_test(&conf->refcount))
+ conf_free(conf);
return ret;
}
@@ -1601,9 +1606,10 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
"Usernum: %d\r\n",
chan->name, chan->uniqueid, conf->confno, user->user_no);
conf->users--;
+ ast_atomic_fetchadd_int(&conf->refcount, -1);
if (confflags & CONFFLAG_MARKEDUSER)
conf->markedusers--;
- if (!conf->users) {
+ if (!conf->users && !conf->refcount) {
/* No more users -- close this one out */
conf_free(conf);
} else {
@@ -1646,7 +1652,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
}
static struct ast_conference *find_conf(struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin,
- struct ast_flags *confflags)
+ int refcount, struct ast_flags *confflags)
{
struct ast_config *cfg;
struct ast_variable *var;
@@ -1658,6 +1664,8 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
if (!strcmp(confno, cnf->confno))
break;
}
+ if (cnf)
+ ast_atomic_fetchadd_int(&cnf->refcount, refcount);
ast_mutex_unlock(&conflock);
if (!cnf) {
@@ -1670,9 +1678,9 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
if (ast_app_getdata(chan, "conf-getpin", dynamic_pin, AST_MAX_EXTENSION - 1, 0) < 0)
return NULL;
}
- cnf = build_conf(confno, dynamic_pin, "", make, dynamic);
+ cnf = build_conf(confno, dynamic_pin, "", make, dynamic, refcount);
} else {
- cnf = build_conf(confno, "", "", make, dynamic);
+ cnf = build_conf(confno, "", "", make, dynamic, refcount);
}
} else {
/* Check the config */
@@ -1694,14 +1702,14 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
/* Bingo it's a valid conference */
if (pin)
if (pinadmin)
- cnf = build_conf(confno, pin, pinadmin, make, dynamic);
+ cnf = build_conf(confno, pin, pinadmin, make, dynamic, refcount);
else
- cnf = build_conf(confno, pin, "", make, dynamic);
+ cnf = build_conf(confno, pin, "", make, dynamic, refcount);
else
if (pinadmin)
- cnf = build_conf(confno, "", pinadmin, make, dynamic);
+ cnf = build_conf(confno, "", pinadmin, make, dynamic, refcount);
else
- cnf = build_conf(confno, "", "", make, dynamic);
+ cnf = build_conf(confno, "", "", make, dynamic, refcount);
break;
}
}
@@ -1764,10 +1772,11 @@ static int count_exec(struct ast_channel *chan, void *data)
}
confnum = strsep(&localdata,"|");
- conf = find_conf(chan, confnum, 0, 0, NULL, NULL);
- if (conf)
+ conf = find_conf(chan, confnum, 0, 0, NULL, 1, NULL);
+ if (conf) {
count = conf->users;
- else
+ ast_atomic_fetchadd_int(&conf->refcount, -1);
+ } else
count = 0;
if (!ast_strlen_zero(localdata)){
@@ -1952,7 +1961,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
}
if (!ast_strlen_zero(confno)) {
/* Check the validity of the conference */
- cnf = find_conf(chan, confno, 1, dynamic, the_pin, &confflags);
+ cnf = find_conf(chan, confno, 1, dynamic, the_pin, 1, &confflags);
if (!cnf) {
res = ast_streamfile(chan, "conf-invalid", chan->language);
if (!res)
@@ -1998,8 +2007,13 @@ static int conf_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "Couldn't play invalid pin msg!\n");
break;
}
- if (res < 0)
+ if (res < 0) {
+ ast_mutex_lock(&conflock);
+ if (ast_atomic_dec_and_test(&cnf->refcount))
+ conf_free(cnf);
+ ast_mutex_unlock(&conflock);
break;
+ }
pin[0] = res;
pin[1] = '\0';
res = -1;
@@ -2012,9 +2026,8 @@ static int conf_exec(struct ast_channel *chan, void *data)
allowretry = 0;
/* see if we need to get rid of the conference */
ast_mutex_lock(&conflock);
- if (!cnf->users) {
+ if (ast_atomic_dec_and_test(&cnf->refcount))
conf_free(cnf);
- }
ast_mutex_unlock(&conflock);
break;
}