Skip to content

Commit

Permalink
Add debug to see if session is locked or not on cancel.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Oct 25, 2024
1 parent 70741e4 commit 7577216
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions sippy/ua.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ import (
"github.com/sippy/go-b2bua/sippy/utils"
)

type SessionLocker interface {
sync.Locker
TryLock() bool
}

type Ua struct {
sip_tm sippy_types.SipTransactionManager
sip_tm_lock sync.RWMutex
config sippy_conf.Config
call_controller sippy_types.CallController
session_lock sync.Locker
session_lock SessionLocker
state sippy_types.UaState
equeue []sippy_types.CCEvent
elast_seq int64
Expand Down Expand Up @@ -131,7 +136,7 @@ func (self *Ua) String() string {
return "UA state: " + self.state.String() + ", Call-Id: " + self.cId.CallId
}

func NewUA(sip_tm sippy_types.SipTransactionManager, config sippy_conf.Config, nh_address *sippy_net.HostPort, call_controller sippy_types.CallController, session_lock sync.Locker, heir sippy_types.UA) *Ua {
func NewUA(sip_tm sippy_types.SipTransactionManager, config sippy_conf.Config, nh_address *sippy_net.HostPort, call_controller sippy_types.CallController, session_lock SessionLocker, heir sippy_types.UA) *Ua {
return &Ua{
sip_tm : sip_tm,
call_controller : call_controller,
Expand Down Expand Up @@ -222,9 +227,17 @@ REQ_LOOP:
if self.pr_rel {
t.SetPrackCBs(self.RecvPRACK, disc_fn)
}
cancel_cb := self.state.RecvCancel
cancel_fn := func(rtime *sippy_time.MonoTime, req sippy_types.SipRequest) {
if self.session_lock.TryLock() {
self.session_lock.Unlock()
panic("self.session_lock is not locked")
}
cancel_cb(rtime, req)
}
return &sippy_types.Ua_context{
Response : nil,
CancelCB : self.state.RecvCancel,
CancelCB : cancel_fn,
NoAckCB : disc_fn,
}
} else {
Expand Down

0 comments on commit 7577216

Please sign in to comment.