Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 152927) +++ channels/chan_sip.c (working copy) @@ -12865,6 +12865,20 @@ gettag(req, "To", tag, sizeof(tag)); ast_string_field_set(p, theirtag, tag); } + + /* RFC 3261 Section 15 specifies that if we receive a 408 or 481 + * in response to a BYE, then we should end the current dialog + * and session. There is no mention in the spec of other 4XX responses, + * but it is known that at least one phone manufacturer potentially + * will send a 404 in response to a BYE, so we'll be liberal in what + * we accept and end the dialog and session if we receive any 4XX + * response to a BYE. + */ + if (resp >= 400 && resp < 500 && sipmethod == SIP_BYE) { + ast_set_flag(&p->flags[0], SIP_NEEDDESTROY); + return; + } + if (p->relatedpeer && p->method == SIP_OPTIONS) { /* We don't really care what the response is, just that it replied back. Well, as long as it's not a 100 response... since we might