Skip to content

Commit cb97c36

Browse files
committed
Cancel register-refresh goroutine after un-registered.
1 parent c10e7e9 commit cb97c36

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/register/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func main() {
5353
Password: "100",
5454
Realm: "b2bua",
5555
},
56-
30,
56+
1800,
5757
stack,
5858
)
5959

pkg/ua/register.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (r *Register) SendRegister(expires uint32) error {
5050

5151
contact := profile.Contact()
5252

53-
if r.request == nil {
53+
if r.request == nil || expires == 0 {
5454
request, err := ua.buildRequest(sip.REGISTER, from, to, contact, recipient, nil)
5555
if err != nil {
5656
ua.Log().Errorf("Register: err = %v", err)
@@ -138,6 +138,7 @@ func (r *Register) SendRegister(expires uint32) error {
138138
r.timer.Stop()
139139
r.timer = nil
140140
}
141+
r.cancel()
141142
}
142143
ua.RegisterStateHandler(state)
143144
}

0 commit comments

Comments
 (0)