[Asterisk-cvs] asterisk manager.c,1.84,1.85 pbx.c,1.199,1.200
markster at lists.digium.com
markster at lists.digium.com
Tue Feb 1 20:52:59 CST 2005
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv27729
Modified Files:
manager.c pbx.c
Log Message:
Include uniqueid in response for ManagerOriginate stuff (bug #3439)
Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- manager.c 1 Feb 2005 01:53:24 -0000 1.84
+++ manager.c 2 Feb 2005 02:54:15 -0000 1.85
@@ -823,16 +823,18 @@
struct fast_originate_helper *in = data;
int res;
int reason = 0;
+ struct ast_channel *chan = NULL;
+
if (!ast_strlen_zero(in->app)) {
res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1,
!ast_strlen_zero(in->cid_num) ? in->cid_num : NULL,
!ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
- in->variable, in->account);
+ in->variable, in->account, &chan);
} else {
res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
!ast_strlen_zero(in->cid_num) ? in->cid_num : NULL,
!ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
- in->variable, in->account);
+ in->variable, in->account, &chan);
}
if (!res)
manager_event(EVENT_FLAG_CALL,
@@ -841,8 +843,9 @@
"Channel: %s/%s\r\n"
"Context: %s\r\n"
"Exten: %s\r\n"
- "Reason: %i\r\n",
- in->idtext, in->tech, in->data, in->context, in->exten, reason);
+ "Reason: %i\r\n"
+ "Uniqueid: %s\r\n",
+ in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "<null>");
else
manager_event(EVENT_FLAG_CALL,
"OriginateFailure",
@@ -850,9 +853,13 @@
"Channel: %s/%s\r\n"
"Context: %s\r\n"
"Exten: %s\r\n"
- "Reason: %i\r\n",
- in->idtext, in->tech, in->data, in->context, in->exten, reason);
+ "Reason: %i\r\n"
+ "Uniqueid: %s\r\n",
+ in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "<null>");
+ /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */
+ if (chan)
+ ast_mutex_unlock(&chan->lock);
free(in);
return NULL;
}
@@ -961,10 +968,10 @@
}
}
} else if (!ast_strlen_zero(app)) {
- res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 0, l, n, variable, account);
+ res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 0, l, n, variable, account, NULL);
} else {
if (exten && context && pi)
- res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 0, l, n, variable, account);
+ res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 0, l, n, variable, account, NULL);
else {
astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
return 0;
Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -d -r1.199 -r1.200
--- pbx.c 1 Feb 2005 01:53:24 -0000 1.199
+++ pbx.c 2 Feb 2005 02:54:15 -0000 1.200
@@ -4352,7 +4352,7 @@
return 0; /* success */
}
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, const char *variable, const char *account)
+int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, const char *variable, const char *account, struct ast_channel **channel)
{
struct ast_channel *chan;
struct async_stat *as;
@@ -4364,6 +4364,11 @@
if (sync) {
LOAD_OH(oh);
chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh);
+ if (channel) {
+ *channel = chan;
+ if (chan)
+ ast_mutex_lock(&chan->lock);
+ }
if (chan) {
if (account)
@@ -4452,6 +4457,11 @@
return -1;
memset(as, 0, sizeof(struct async_stat));
chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name);
+ if (channel) {
+ *channel = chan;
+ if (chan)
+ ast_mutex_lock(&chan->lock);
+ }
if (!chan) {
free(as);
return -1;
@@ -4504,7 +4514,7 @@
return NULL;
}
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, const char *variable, const char *account)
+int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, const char *variable, const char *account, struct ast_channel **locked_channel)
{
struct ast_channel *chan;
struct async_stat *as;
@@ -4513,12 +4523,13 @@
int res = -1, cdr_res = -1;
pthread_attr_t attr;
+ if (locked_channel)
+ *locked_channel = NULL;
if (!app || ast_strlen_zero(app))
return -1;
if (sync) {
chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name);
if (chan) {
-
if (account)
ast_cdr_setaccount(chan, account);
@@ -4558,11 +4569,18 @@
} else {
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (locked_channel)
+ ast_mutex_lock(&chan->lock);
if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) {
ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
free(tmp);
+ if (locked_channel)
+ ast_mutex_unlock(&chan->lock);
ast_hangup(chan);
res = -1;
+ } else {
+ if (locked_channel)
+ *locked_channel = chan;
}
}
} else {
@@ -4616,11 +4634,18 @@
/* Start a new thread, and get something handling this channel. */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (locked_channel)
+ ast_mutex_lock(&chan->lock);
if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
ast_log(LOG_WARNING, "Failed to start async wait\n");
free(as);
+ if (locked_channel)
+ ast_mutex_unlock(&chan->lock);
ast_hangup(chan);
return -1;
+ } else {
+ if (locked_channel)
+ *locked_channel = chan;
}
res = 0;
}
More information about the svn-commits
mailing list