Skip to content

fix: register dialog state read channel before sending 200 OK#285

Merged
emiago merged 1 commit intoemiago:mainfrom
alexbakker:ack-race
Feb 2, 2026
Merged

fix: register dialog state read channel before sending 200 OK#285
emiago merged 1 commit intoemiago:mainfrom
alexbakker:ack-race

Conversation

@alexbakker
Copy link
Contributor

This patch addresses a race where the 200 OK would be retransmitted forever because the ACK arrived before we started waiting for dialog state changes.

The easiest way to reproduce this is to either produce lots of load and get lucky, or introduce a short sleep after sending the 200 OK, causing it to be retransmitted forever (and eventually return an error after a timeout):

diff --git a/dialog_server.go b/dialog_server.go
index e9b3a0e..03067f9 100644
--- a/dialog_server.go
+++ b/dialog_server.go
@@ -314,6 +314,8 @@ func (s *DialogServerSession) WriteResponse(res *sip.Response) error {
                return err
        }

+       time.Sleep(10 * time.Millisecond)
+
        // Wait now for ACK for our 2xx
        // https://datatracker.ietf.org/doc/html/rfc3261#section-13.3.1.4

This patch addresses a race where the 200 OK would be retransmitted
forever because the ACK arrived before we started waiting for dialog
state changes.

The easiest way to reproduce this is to either produce lots of load and
get lucky, or introduce a short sleep after sending the 200 OK, causing
it to be retransmitted forever (and eventually return an error after a
timeout):

```diff
diff --git a/dialog_server.go b/dialog_server.go
index e9b3a0e..03067f9 100644
--- a/dialog_server.go
+++ b/dialog_server.go
@@ -314,6 +314,8 @@ func (s *DialogServerSession) WriteResponse(res *sip.Response) error {
                return err
        }

+       time.Sleep(10 * time.Millisecond)
+
        // Wait now for ACK for our 2xx
        // https://datatracker.ietf.org/doc/html/rfc3261#section-13.3.1.4
```
@emiago emiago merged commit 33ae90e into emiago:main Feb 2, 2026
1 check passed
@emiago
Copy link
Owner

emiago commented Feb 2, 2026

Nice! 👍

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.

2 participants