Index: manager.c =================================================================== RCS file: /usr/cvsroot/asterisk/manager.c,v retrieving revision 1.84 diff -u -r1.84 manager.c --- manager.c 1 Feb 2005 01:53:24 -0000 1.84 +++ manager.c 1 Feb 2005 07:23:36 -0000 @@ -823,16 +818,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 : ""); else manager_event(EVENT_FLAG_CALL, "OriginateFailure", @@ -851,8 +854,12 @@ "Context: %s\r\n" "Exten: %s\r\n" "Reason: %i\r\n", - in->idtext, in->tech, in->data, in->context, in->exten, reason); + "Uniqueid: %s\r\n", + in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : ""); + /* 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 diff -u -r1.199 pbx.c --- pbx.c 1 Feb 2005 01:53:24 -0000 1.199 +++ pbx.c 1 Feb 2005 07:23:36 -0000 @@ -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; @@ -4517,6 +4527,11 @@ return -1; if (sync) { chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name); + if (locked_channel) { + *locked_channel = chan; + if (chan) + ast_mutex_lock(&chan->lock); + } if (chan) { if (account) @@ -4597,6 +4612,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 (locked_channel) { + *locked_channel = chan; + if (chan) + ast_mutex_lock(&chan->lock); + } if (!chan) { free(as); return -1; Index: pbx/pbx_spool.c =================================================================== RCS file: /usr/cvsroot/asterisk/pbx/pbx_spool.c,v retrieving revision 1.18 diff -u -r1.18 pbx_spool.c --- pbx/pbx_spool.c 21 Jan 2005 07:06:25 -0000 1.18 +++ pbx/pbx_spool.c 1 Feb 2005 07:23:36 -0000 @@ -224,11 +224,11 @@ if (!ast_strlen_zero(o->app)) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries); - res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->variable, o->account); + res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->variable, o->account, NULL); } else { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries); - res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->variable, o->account); + res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->variable, o->account, NULL); } if (res) { ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason); Index: include/asterisk/pbx.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/pbx.h,v retrieving revision 1.40 diff -u -r1.40 pbx.h --- include/asterisk/pbx.h 1 Feb 2005 01:53:25 -0000 1.40 +++ include/asterisk/pbx.h 1 Feb 2005 07:23:36 -0000 @@ -526,11 +526,11 @@ /* Synchronously or asynchronously make an outbound call and send it to a particular extension */ -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 **locked_channel); /* Synchronously or asynchronously make an outbound call and send it to a particular application with given extension */ -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); /* Functions for returning values from structures */ const char *ast_get_context_name(struct ast_context *con);