--- asterisk-orig/channels/chan_zap.c 2005-06-08 17:44:30.712963400 +0200 +++ asterisk/channels/chan_zap.c 2005-06-08 17:57:16.712513768 +0200 @@ -3486,13 +3486,23 @@ /* 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) - p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; - else if (res) { - /* Don't actually hang up at this point */ - if (p->subs[SUB_THREEWAY].owner) - ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); - break; + if(p->owner->_state == AST_STATE_RINGING){ + /* Only attempt transfer if the phone is ringing; why transfer to busy tone eh? */ + if ((res = attempt_transfer(p)) < 0) + p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; + else if (res) { + /* Don't actually hang up at this point */ + if (p->subs[SUB_THREEWAY].owner) + ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); + break; + } + } else { + ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); + /* Swap subs and dis-own channel */ + swap_subs(p, SUB_THREEWAY, SUB_REAL); + p->owner = NULL; + /* Ring the phone */ + zt_ring_phone(p); } } else p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;