Minor fixes
parent
0e87287035
commit
fb9a83de56
2
main.go
2
main.go
|
@ -111,8 +111,6 @@ func (h *Handler) watchClose() {
|
||||||
if id == "" {
|
if id == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Closing stream", id)
|
|
||||||
h.removeManager(id)
|
h.removeManager(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
manager.go
13
manager.go
|
@ -94,6 +94,12 @@ func NewManager(c *Config, path string, id string, close chan string) (*Manager,
|
||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
for {
|
for {
|
||||||
<-t.C
|
<-t.C
|
||||||
|
|
||||||
|
if m.inactive == -1 {
|
||||||
|
t.Stop()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
m.inactive++
|
m.inactive++
|
||||||
|
|
||||||
// Check if any stream is active
|
// Check if any stream is active
|
||||||
|
@ -105,8 +111,8 @@ func NewManager(c *Config, path string, id string, close chan string) (*Manager,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing done for 5 minutes
|
// Nothing done for 5 minutes
|
||||||
if m.inactive >= 60 {
|
if m.inactive >= 4 {
|
||||||
log.Printf("%s: inactive, closing", m.id)
|
t.Stop()
|
||||||
m.Destroy()
|
m.Destroy()
|
||||||
m.close <- m.id
|
m.close <- m.id
|
||||||
return
|
return
|
||||||
|
@ -119,6 +125,9 @@ func NewManager(c *Config, path string, id string, close chan string) (*Manager,
|
||||||
|
|
||||||
// Destroys streams. DOES NOT emit on the close channel.
|
// Destroys streams. DOES NOT emit on the close channel.
|
||||||
func (m *Manager) Destroy() {
|
func (m *Manager) Destroy() {
|
||||||
|
log.Printf("%s: destroying manager", m.id)
|
||||||
|
m.inactive = -1
|
||||||
|
|
||||||
for _, stream := range m.streams {
|
for _, stream := range m.streams {
|
||||||
stream.Stop()
|
stream.Stop()
|
||||||
}
|
}
|
||||||
|
|
10
stream.go
10
stream.go
|
@ -69,16 +69,13 @@ func (s *Stream) Run() {
|
||||||
s.inactive++
|
s.inactive++
|
||||||
|
|
||||||
// Nothing done for 2 minutes
|
// Nothing done for 2 minutes
|
||||||
if s.inactive >= 24 {
|
if s.inactive >= 3 && s.coder != nil {
|
||||||
t.Stop()
|
t.Stop()
|
||||||
s.clear()
|
s.clear()
|
||||||
s.mutex.Unlock()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
s.mutex.Unlock()
|
s.mutex.Unlock()
|
||||||
|
|
||||||
case <-s.stop:
|
case <-s.stop:
|
||||||
log.Printf("%s-%s: received stop signal", s.m.id, s.quality)
|
|
||||||
t.Stop()
|
t.Stop()
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
s.clear()
|
s.clear()
|
||||||
|
@ -106,7 +103,10 @@ func (s *Stream) clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) Stop() {
|
func (s *Stream) Stop() {
|
||||||
s.stop <- true
|
select {
|
||||||
|
case s.stop <- true:
|
||||||
|
default:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) ServeList(w http.ResponseWriter) error {
|
func (s *Stream) ServeList(w http.ResponseWriter) error {
|
||||||
|
|
Loading…
Reference in New Issue