Index: main/pbx.c =================================================================== --- main/pbx.c (revision 45159) +++ main/pbx.c (working copy) @@ -2251,7 +2251,32 @@ } if (c->cdr && ast_tvzero(c->cdr->start)) ast_cdr_start(c->cdr); + + /* Keep a copy of the real asked extension and priority */ + char *real_exten = ast_strdupa(c->exten); + int real_pri = c->priority; + /* Execute the 'b' extension at priority 1 */ + set_ext_pri(c, "b", 1); + while (ast_exists_extension(c, c->context, c->exten, c->priority, c->cid.cid_num)) { + if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) { + /* Something bad happened, or a hangup has been requested. */ + if (option_debug) + ast_log(LOG_DEBUG, "Spawn extension (%s, %s, %d) exited non-zero (res = %d) on '%s'\n", c->context, c->exten, c->priority, res, c->name); + if (option_verbose > 1) + ast_verbose(VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero (res = %d) on '%s'\n", c->context, c->exten, c->priority, res, c->name); + error = 1; + break; + } + c->priority++; + } + /* Put back the real information in the channel */ + set_ext_pri(c, real_exten, real_pri); + for (;;) { + /* Check if error flag was set before going further */ + if (error) + break; + char dst_exten[256]; /* buffer to accumulate digits */ int pos = 0; /* XXX should check bounds */ int digit = 0;