Skip to content

Resolve various crossed-BYE issues - #71

Open
hkrutzer wants to merge 5 commits into
kbalt:mainfrom
hkrutzer:hkr/fix-sip-ua-handle-crossed-bye-tkmukrpoyzyp
Open

hkrutzer wants to merge 5 commits into
kbalt:mainfrom
hkrutzer:hkr/fix-sip-ua-handle-crossed-bye-tkmukrpoyzyp

Conversation

@hkrutzer

@hkrutzer hkrutzer commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

See #70

@hkrutzer
hkrutzer force-pushed the hkr/fix-sip-ua-handle-crossed-bye-tkmukrpoyzyp branch from ab645f1 to 0965d24 Compare September 9, 2026 19:48
@hkrutzer
hkrutzer force-pushed the hkr/fix-sip-ua-handle-crossed-bye-tkmukrpoyzyp branch 2 times, most recently from 61e90d4 to e03d0da Compare October 28, 2026 19:34
@hkrutzer
hkrutzer force-pushed the hkr/fix-sip-ua-handle-crossed-bye-tkmukrpoyzyp branch from e03d0da to b6e47c3 Compare October 28, 2026 21:47
- terminate() held the session state lock until our BYE received a final
  response. The incoming BYE needs that lock, so it could not be answered
  in the meantime.

- Once the session was terminated, an incoming BYE was ignored and fell
  through to the dialog layer, which answered it with 404 Not Found.
A caller can send BYE after receiving a provisional INVITE response, before
we have accepted the call. In this case we send two separate responses:
200 OK for the BYE, and 487 Request Terminated for the pending INVITE.

The 200 OK was built from the INVITE instead of the BYE. It therefore
carried the INVITE's Via branch and CSeq. The peer saw it as a response to
the INVITE, not the BYE. Its BYE could time out, while its INVITE appeared
to receive both a success and a failure response.

Build the 200 OK from the BYE so each response answers the right request.
A BYE that crossed ours could arrive after the application dropped the
InviteSession (e.g. via Call::terminate) while our BYE client transaction
was still in its Completed state. The dialog and INVITE usage were already
gone, so the crossed BYE got 481.

terminate() now retains the usage guard and dialog for T4 after a final
response over UDP, matching the transaction lifetime. This follows the
RFC 5407 Mortal state, in which a crossed BYE is answered with 200 OK
(§3.2.1 notes an error response is also acceptable).
@hkrutzer
hkrutzer force-pushed the hkr/fix-sip-ua-handle-crossed-bye-tkmukrpoyzyp branch from b6e47c3 to 7bc4cd7 Compare October 31, 2026 13:49
@hkrutzer hkrutzer changed the title fix(sip-ua): handle crossed BYE during session termination Resolve various crossed-BYE issues Oct 31, 2026
@hkrutzer
hkrutzer marked this pull request as ready for review October 31, 2026 14:06
@hkrutzer

Copy link
Copy Markdown
Contributor Author

@kbalt please take a look when you have time. This should resolve most issues around crossed BYEs, there is one that remains that I'm aware of, that can happen when the session event queue is full, that I haven't solved yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant