Skip to content

Commit de11eef

Browse files
authored
Fix media timeout when getting no ACK. (#508)
1 parent 1ebc507 commit de11eef

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

pkg/sip/media_port.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ func (p *MediaPort) disableTimeout() {
229229
}
230230

231231
func (p *MediaPort) enableTimeout(initial, general time.Duration) {
232+
if initial <= 0 || general <= 0 {
233+
p.log.Warnw("attempting to set zero media timeout", nil, "initial", initial, "timeout", general)
234+
if initial <= 0 {
235+
initial = defaultMediaTimeoutInitial
236+
}
237+
if general <= 0 {
238+
general = defaultMediaTimeout
239+
}
240+
}
232241
p.timeoutInitial.Store(&initial)
233242
p.timeoutGeneral.Store(&general)
234243
select {
@@ -253,10 +262,6 @@ func (p *MediaPort) EnableTimeout(enabled bool) {
253262
}
254263

255264
func (p *MediaPort) SetTimeout(initial, general time.Duration) {
256-
if initial <= 0 {
257-
p.disableTimeout()
258-
return
259-
}
260265
p.enableTimeout(initial, general)
261266
}
262267

pkg/sip/service.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ func NewService(region string, conf *config.Config, mon *stats.Monitor, log logg
7373
if log == nil {
7474
log = logger.GetLogger()
7575
}
76+
if conf.MediaTimeout <= 0 {
77+
conf.MediaTimeout = defaultMediaTimeout
78+
}
79+
if conf.MediaTimeoutInitial <= 0 {
80+
conf.MediaTimeoutInitial = defaultMediaTimeoutInitial
81+
}
7682
s := &Service{
7783
conf: conf,
7884
log: log,

0 commit comments

Comments
 (0)