Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 351448) +++ channels/chan_sip.c (working copy) @@ -3868,6 +3868,7 @@ ast_channel_unlock(p->owner); } else if (p->refer && !p->alreadygone) { ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid); + stop_media_flows(p); transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1); append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid); sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); @@ -19852,15 +19853,22 @@ case 200: /* Notify accepted */ /* They got the notify, this is the end */ if (p->owner) { - if (!p->refer) { - ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name); - ast_queue_hangup_with_cause(p->owner, AST_CAUSE_NORMAL_UNSPECIFIED); + if (p->refer) { + ast_log(LOG_NOTICE, "Got OK on REFER Notify message\n"); } else { - ast_debug(4, "Got OK on REFER Notify message\n"); + ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name); + /* + * XXX There is discrepancy on whether a hangup should be queued + * or not. This code used to be duplicated in two places, and the more + * frequently hit area had this disabled, making it the de facto + * "correct" way to go. + * + * ast_queue_hangup_with_cause(p->owner, AST_CAUSE_NORMAL_UNSPECIFIED); + */ } } else { - if (p->subscribed == NONE) { - ast_debug(4, "Got 200 accepted on NOTIFY\n"); + if (p->subscribed == NONE && !p->refer) { + ast_debug(4, "Got 200 accepted on NOTIFY %s\n", p->callid); pvt_set_needdestroy(p, "received 200 response"); } if (ast_test_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE)) { @@ -19885,6 +19893,9 @@ pvt_set_needdestroy(p, "failed to authenticate NOTIFY"); } break; + case 481: /* Call leg does not exist */ + pvt_set_needdestroy(p, "Received 481 response for NOTIFY"); + break; } } @@ -20473,6 +20484,9 @@ } else if (sipmethod == SIP_MESSAGE) { /* More good gravy! */ handle_response_message(p, resp, rest, req, seqno); + } else if (sipmethod == SIP_NOTIFY) { + /* The gravy train continues to roll */ + handle_response_notify(p, resp, rest, req, seqno); } else if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) { switch(resp) { case 100: /* 100 Trying */ @@ -20488,8 +20502,6 @@ p->authtries = 0; /* Reset authentication counter */ if (sipmethod == SIP_INVITE) { handle_response_invite(p, resp, rest, req, seqno); - } else if (sipmethod == SIP_NOTIFY) { - handle_response_notify(p, resp, rest, req, seqno); } else if (sipmethod == SIP_REGISTER) { handle_response_register(p, resp, rest, req, seqno); } else if (sipmethod == SIP_SUBSCRIBE) { @@ -20504,8 +20516,6 @@ case 407: /* Proxy auth required */ if (sipmethod == SIP_INVITE) handle_response_invite(p, resp, rest, req, seqno); - else if (sipmethod == SIP_NOTIFY) - handle_response_notify(p, resp, rest, req, seqno); else if (sipmethod == SIP_SUBSCRIBE) handle_response_subscribe(p, resp, rest, req, seqno); else if (p->registry && sipmethod == SIP_REGISTER) @@ -20580,8 +20590,6 @@ handle_response_invite(p, resp, rest, req, seqno); } else if (sipmethod == SIP_SUBSCRIBE) { handle_response_subscribe(p, resp, rest, req, seqno); - } else if (sipmethod == SIP_NOTIFY) { - pvt_set_needdestroy(p, "received 481 response"); } else if (sipmethod == SIP_BYE) { /* The other side has no transaction to bye, just assume it's all right then */ @@ -20735,24 +20743,6 @@ ast_debug(1, "Got 200 OK on CANCEL\n"); /* Wait for 487, then destroy */ - } else if (sipmethod == SIP_NOTIFY) { - /* They got the notify, this is the end */ - if (p->owner) { - if (p->refer) { - ast_debug(1, "Got 200 OK on NOTIFY for transfer\n"); - } else - ast_log(LOG_WARNING, "Notify answer on an owned channel?\n"); - /* ast_queue_hangup(p->owner); Disabled */ - } else { - if (!p->subscribed && !p->refer) { - pvt_set_needdestroy(p, "transaction completed"); - } - if (ast_test_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE)) { - /* Ready to send the next state we have on queue */ - ast_clear_flag(&p->flags[1], SIP_PAGE2_STATECHANGEQUEUE); - cb_extensionstate((char *)p->context, (char *)p->exten, p->laststate, (void *) p); - } - } } else if (sipmethod == SIP_BYE) { pvt_set_needdestroy(p, "transaction completed"); } @@ -20774,8 +20764,6 @@ handle_response_invite(p, resp, rest, req, seqno); } else if (sipmethod == SIP_BYE) { pvt_set_needdestroy(p, "received 481 response"); - } else if (sipmethod == SIP_NOTIFY) { - pvt_set_needdestroy(p, "received 481 response"); } else if (sipdebug) { ast_debug(1, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid); }