Minor fixes
parent
0e87287035
commit
fb9a83de56
2
main.go
2
main.go
|
@ -111,8 +111,6 @@ func (h *Handler) watchClose() {
|
|||
if id == "" {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Closing stream", 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()
|
||||
for {
|
||||
<-t.C
|
||||
|
||||
if m.inactive == -1 {
|
||||
t.Stop()
|
||||
return
|
||||
}
|
||||
|
||||
m.inactive++
|
||||
|
||||
// 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
|
||||
if m.inactive >= 60 {
|
||||
log.Printf("%s: inactive, closing", m.id)
|
||||
if m.inactive >= 4 {
|
||||
t.Stop()
|
||||
m.Destroy()
|
||||
m.close <- m.id
|
||||
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.
|
||||
func (m *Manager) Destroy() {
|
||||
log.Printf("%s: destroying manager", m.id)
|
||||
m.inactive = -1
|
||||
|
||||
for _, stream := range m.streams {
|
||||
stream.Stop()
|
||||
}
|
||||
|
|
10
stream.go
10
stream.go
|
@ -69,16 +69,13 @@ func (s *Stream) Run() {
|
|||
s.inactive++
|
||||
|
||||
// Nothing done for 2 minutes
|
||||
if s.inactive >= 24 {
|
||||
if s.inactive >= 3 && s.coder != nil {
|
||||
t.Stop()
|
||||
s.clear()
|
||||
s.mutex.Unlock()
|
||||
return
|
||||
}
|
||||
s.mutex.Unlock()
|
||||
|
||||
case <-s.stop:
|
||||
log.Printf("%s-%s: received stop signal", s.m.id, s.quality)
|
||||
t.Stop()
|
||||
s.mutex.Lock()
|
||||
s.clear()
|
||||
|
@ -106,7 +103,10 @@ func (s *Stream) clear() {
|
|||
}
|
||||
|
||||
func (s *Stream) Stop() {
|
||||
s.stop <- true
|
||||
select {
|
||||
case s.stop <- true:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Stream) ServeList(w http.ResponseWriter) error {
|
||||
|
|
Loading…
Reference in New Issue