diff -uNr clean/asterisk-1.4.6/channels/chan_sip.c asterisk-1.4.6/channels/chan_sip.c --- clean/asterisk-1.4.6/channels/chan_sip.c 2007-06-25 03:10:06.000000000 +0200 +++ asterisk-1.4.6/channels/chan_sip.c 2007-07-10 22:39:54.000000000 +0200 @@ -13194,7 +13218,8 @@ ast_mutex_unlock(&p->refer->refer_call->lock); /* Make sure that the masq does not free our PVT for the old call */ - ast_set_flag(&p->refer->refer_call->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Delay hangup */ + if (! earlyreplace && ! oneleggedreplace ) + ast_set_flag(&p->refer->refer_call->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Delay hangup */ /* Prepare the masquerade - if this does not happen, we will be gone */ if(ast_channel_masquerade(replacecall, c)) @@ -13411,7 +13436,7 @@ error = 1; } - if (!error && p->refer->refer_call->owner->_state != AST_STATE_RING && p->refer->refer_call->owner->_state != AST_STATE_UP ) { + if (!error && p->refer->refer_call->owner->_state != AST_STATE_RINGING && p->refer->refer_call->owner->_state != AST_STATE_RING && p->refer->refer_call->owner->_state != AST_STATE_UP ) { ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-ringing or active call id (%s)!\n", replace_id); transmit_response(p, "603 Declined (Replaces)", req); error = 1;