--- chan_zap.c.orig 2003-12-19 10:05:40.000000000 -0800 +++ chan_zap.c 2004-01-13 14:11:51.000000000 -0800 @@ -1,3 +1,5 @@ +/* calltrex-modifications so uncomplete transfers won't crash asterisk */ + /* * Asterisk -- A telephony toolkit for Linux. * @@ -1710,18 +1712,21 @@ } } else if (p->subs[SUB_CALLWAIT].zfd > -1) { /* Move to the call-wait and switch back to them. */ + ast_log(LOG_DEBUG, "Move to the call-wait and switch back to them.\n"); swap_subs(p, SUB_CALLWAIT, SUB_REAL); unalloc_sub(p, SUB_CALLWAIT); p->owner = p->subs[SUB_REAL].owner; if (p->subs[SUB_REAL].owner->bridge) ast_moh_stop(p->subs[SUB_REAL].owner->bridge); } else if (p->subs[SUB_THREEWAY].zfd > -1) { - swap_subs(p, SUB_THREEWAY, SUB_REAL); - unalloc_sub(p, SUB_THREEWAY); + ast_log(LOG_DEBUG, "(not) Move to the call-wait and switch back to them.\n"); if (p->subs[SUB_REAL].inthreeway) { /* This was part of a three way call. Immediately make way for another call */ ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n"); + swap_subs(p, SUB_THREEWAY, SUB_REAL); + unalloc_sub(p, SUB_THREEWAY); p->owner = p->subs[SUB_REAL].owner; } else { /* This call hasn't been completed yet... Set owner to NULL */ @@ -1732,6 +1737,7 @@ } } else if (index == SUB_CALLWAIT) { /* Ditch the holding callwait call, and immediately make it availabe */ + ast_log(LOG_DEBUG, "Ditch the holding callwait call, and immediately make it availabe\n"); if (p->subs[SUB_CALLWAIT].inthreeway) { /* This is actually part of a three way, placed on hold. Place the third part on music on hold now */ @@ -1739,6 +1745,7 @@ ast_moh_start(p->subs[SUB_THREEWAY].owner->bridge, NULL); p->subs[SUB_THREEWAY].inthreeway = 0; /* Make it the call wait now */ + ast_log(LOG_DEBUG, "Make it the call wait now\n"); swap_subs(p, SUB_CALLWAIT, SUB_THREEWAY); unalloc_sub(p, SUB_THREEWAY); } else @@ -2818,6 +2825,7 @@ gettimeofday(&tv, NULL); mssinceflash = (tv.tv_sec - p->flashtime.tv_sec) * 1000 + (tv.tv_usec - p->flashtime.tv_usec) / 1000; ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash); + ast_log(LOG_DEBUG, "AST_STATE_UP: %d ast->pbx %p\n", ast->_state, ast->pbx); if (mssinceflash < MIN_MS_SINCE_FLASH) { /* It hasn't been long enough since the last flashook. This is probably a bounce on hanging up. Hangup both channels now */ @@ -2827,21 +2835,29 @@ ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel); } else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) { + ast_log(LOG_DEBUG, "AST_STATE_UP\n"); if (p->transfer) { + ast_log(LOG_DEBUG, "p->transfer: %d\n", p->transfer); /* In any case this isn't a threeway call anymore */ p->subs[SUB_REAL].inthreeway = 0; p->subs[SUB_THREEWAY].inthreeway = 0; - if ((res = attempt_transfer(p)) < 0) + if ((res = attempt_transfer(p)) < 0) { + ast_log(LOG_DEBUG, "attempt_transfer: %d\n", res); p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; + } else if (res) { + ast_log(LOG_DEBUG, "attempt_transfer(else): %d\n", res); /* Don't actually hang up at this point */ break; } - } else + } else { + ast_log(LOG_DEBUG, "1: AST_SOFTHANGUP_DEV\n"); p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; + } } else { + ast_log(LOG_DEBUG, "2: AST_SOFTHANGUP_DEV\n"); /* Swap subs and dis-own channel */ - swap_subs(p, SUB_THREEWAY, SUB_REAL); + //swap_subs(p, SUB_THREEWAY, SUB_REAL); p->owner = NULL; /* Ring the phone */ zt_ring_phone(p); @@ -3998,6 +4014,7 @@ } if (p->dsp) ast_dsp_digitreset(p->dsp); + switch(p->sig) { case SIG_FEATD: case SIG_FEATDMF: @@ -5794,10 +5811,13 @@ time(&t); ast_mutex_lock(&pri->lock); if (pri->resetting && pri->up) { - if (!pri->resetchannel) + if (!pri->resetchannel) { + ast_log(LOG_DEBUG, "entering pri_check_restart\n"); pri_check_restart(pri); + } } else { if (!pri->resetting && ((t - pri->lastreset) >= RESET_INTERVAL)) { + ast_log(LOG_DEBUG, "setting up pri for reset\n"); pri->resetting = 1; pri->resetchannel = 0; }