Skip to content

Fix coupling between tx.Receive() and 200OK write. Fix ACK missed wa…#289

Closed
csiwek wants to merge 3 commits intoemiago:mainfrom
csiwek:main
Closed

Fix coupling between tx.Receive() and 200OK write. Fix ACK missed wa…#289
csiwek wants to merge 3 commits intoemiago:mainfrom
csiwek:main

Conversation

@csiwek
Copy link
Copy Markdown
Contributor

@csiwek csiwek commented Mar 11, 2026

Fix the tight coupling between tx.Receive() which fires the FSM and writes 487 synchronously and the subsequent 200 OK write means there's a window where the UA sees 487 first. Swapping the order is still the right fix

make acks buffered with size 1. The ACK gets queued without blocking

@csiwek
Copy link
Copy Markdown
Contributor Author

csiwek commented Mar 12, 2026

I see the other pr also fixes this.

this branch also includes the missed ACK warning fix

tx.acks = make(chan *Request)
// Buffer of 1 so that ACK delivery (e.g. after CANCEL→487) does not
// block when nobody is reading the channel.
tx.acks = make(chan *Request, 1)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. It should block until transaction is terminated otherwise I think we could refactor this differently. For ex, no need even for goroutines.
Was it some other issue? I would avoid this change for now if not required

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right - this isn't an elegant fix. Let me think of something that will not affect other transactions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pushed another way of dealing with those ACKs. This should not affect anything else but CANCEL related transactions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the ACK handling to another PR


tx.passAck()
// ACK for a CANCEL-triggered 487 is not relevant to the application.
if tx.fsmErr != ErrTransactionCanceled {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how would unreliable transport detect CANCEL was successful.
I see here also issue for OnCancel callback, that could be better or more correct usage after receiving ACK.
On other hand could be issue for shadowing this for proxy.

Can we move this ACK in other PR, or it is anyhow relevant. I understand for reliable could mean nothing due to immediate transaction close.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the CANCEL flow (INVITE → CANCEL → 487 → ACK), the ACK is just the UAC acknowledging it received the 487.
the passAck() will send the ACK to the channel that nothing is reading from. This produces the warning. Happy to split the PR

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes split PR pls, to make this merge.
Reading ACKs I am not sure yet. You could be right in general that makes no sense to consume, just have to justify from proxy perspective.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for a 487 is hop-by-hop. It should be absorbed by the transaction layer

@emiago
Copy link
Copy Markdown
Owner

emiago commented Mar 29, 2026

squashed, rebased and merged

@emiago emiago closed this Mar 29, 2026
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