Skip to content

Commit

Permalink
fix: add more info
Browse files Browse the repository at this point in the history
  • Loading branch information
emiago committed Sep 6, 2024
1 parent 8067400 commit 14cb199
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions dialog_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,12 @@ func TestIntegrationDialogCancel(t *testing.T) {

// Cancel a call
ctx, cancel := context.WithCancel(sess.Context())
cancel()
err = sess.WaitAnswer(ctx, AnswerOptions{})
err = sess.WaitAnswer(ctx, AnswerOptions{OnResponse: func(res *sip.Response) error {
if res.StatusCode == sip.StatusRinging {
cancel()
}
return nil
}})
require.ErrorIs(t, err, context.Canceled)
assert.EqualValues(t, 487, sess.InviteResponse.StatusCode)
}
Expand Down
3 changes: 2 additions & 1 deletion dialog_ua.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ func (c *DialogUA) ReadInvite(inviteReq *sip.Request, tx sip.ServerTransaction)
// Temporarly fix
if stx, ok := tx.(*sip.ServerTx); ok {
stx.OnTerminate(func(key string) {
// TODO use transaction error for better checking why it terminated
state := dtx.LoadState()
if state < sip.DialogStateEstablished {
// It is canceled
// It is canceled if transaction died before answer
dtx.setState(sip.DialogStateEnded)
}
})
Expand Down
1 change: 1 addition & 0 deletions sip/transaction_server_tx_fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ func (tx *ServerTx) actCancel() fsmInput {
}
tx.log.Debug().Msg("Passing 487 on CANCEL")
tx.fsmResp = NewResponseFromRequest(tx.origin, StatusRequestTerminated, "Request Terminated", nil)
tx.fsmErr = fmt.Errorf("Transaction canceled") // For now only informative
return server_input_user_300_plus
}

Expand Down

0 comments on commit 14cb199

Please sign in to comment.