mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -04:00
Fix timing issue with cleanup
This commit is contained in:
parent
7b13733c9e
commit
d630f29753
@ -143,9 +143,9 @@ func GetKeyframes(path string) ([]float64, bool, error) {
|
|||||||
|
|
||||||
func (fs *FileStream) Destroy() {
|
func (fs *FileStream) Destroy() {
|
||||||
fs.vlock.Lock()
|
fs.vlock.Lock()
|
||||||
defer fs.vlock.Lock()
|
defer fs.vlock.Unlock()
|
||||||
fs.alock.Lock()
|
fs.alock.Lock()
|
||||||
defer fs.alock.Lock()
|
defer fs.alock.Unlock()
|
||||||
|
|
||||||
for _, s := range fs.streams {
|
for _, s := range fs.streams {
|
||||||
s.Kill()
|
s.Kill()
|
||||||
|
@ -151,7 +151,6 @@ func (ts *Stream) run(start int32) error {
|
|||||||
|
|
||||||
ts.lock.Lock()
|
ts.lock.Lock()
|
||||||
ts.heads[encoder_id] = segment
|
ts.heads[encoder_id] = segment
|
||||||
log.Printf("encode %d finished %d", encoder_id, segment)
|
|
||||||
if ts.isSegmentReady(segment) {
|
if ts.isSegmentReady(segment) {
|
||||||
// the current segment is already marked at done so another process has already gone up to here.
|
// the current segment is already marked at done so another process has already gone up to here.
|
||||||
cmd.Process.Signal(os.Interrupt)
|
cmd.Process.Signal(os.Interrupt)
|
||||||
|
@ -47,8 +47,8 @@ func (t *Tracker) start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
old, ok := t.clients[info.client]
|
old, ok := t.clients[info.client]
|
||||||
|
// First fixup the info. Most routes ruturn partial infos
|
||||||
if ok && old.path == info.path {
|
if ok && old.path == info.path {
|
||||||
// First fixup the info. Most routes ruturn partial infos
|
|
||||||
if info.quality == nil {
|
if info.quality == nil {
|
||||||
info.quality = old.quality
|
info.quality = old.quality
|
||||||
}
|
}
|
||||||
@ -58,7 +58,13 @@ func (t *Tracker) start() {
|
|||||||
if info.head == -1 {
|
if info.head == -1 {
|
||||||
info.head = old.head
|
info.head = old.head
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.clients[info.client] = info
|
||||||
|
t.visitDate[info.client] = time.Now()
|
||||||
|
|
||||||
|
// now that the new info is stored and fixed, kill old streams
|
||||||
|
if ok && old.path == info.path {
|
||||||
if old.audio != info.audio && old.audio != -1 {
|
if old.audio != info.audio && old.audio != -1 {
|
||||||
t.KillAudioIfDead(old.path, old.audio)
|
t.KillAudioIfDead(old.path, old.audio)
|
||||||
}
|
}
|
||||||
@ -72,9 +78,6 @@ func (t *Tracker) start() {
|
|||||||
t.KillStreamIfDead(old.path)
|
t.KillStreamIfDead(old.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.clients[info.client] = info
|
|
||||||
t.visitDate[info.client] = time.Now()
|
|
||||||
|
|
||||||
case <-timer:
|
case <-timer:
|
||||||
timer = time.After(inactive_time)
|
timer = time.After(inactive_time)
|
||||||
// Purge old clients
|
// Purge old clients
|
||||||
@ -106,6 +109,7 @@ func (t *Tracker) KillStreamIfDead(path string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Printf("Nobody is watching %s. Killing it", path)
|
||||||
t.transcoder.mutex.Lock()
|
t.transcoder.mutex.Lock()
|
||||||
defer t.transcoder.mutex.Unlock()
|
defer t.transcoder.mutex.Unlock()
|
||||||
t.transcoder.streams[path].Destroy()
|
t.transcoder.streams[path].Destroy()
|
||||||
@ -119,6 +123,7 @@ func (t *Tracker) KillAudioIfDead(path string, audio int32) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Printf("Nobody is listening audio %d of %s. Killing it", audio, path)
|
||||||
t.transcoder.mutex.RLock()
|
t.transcoder.mutex.RLock()
|
||||||
stream := t.transcoder.streams[path]
|
stream := t.transcoder.streams[path]
|
||||||
t.transcoder.mutex.RUnlock()
|
t.transcoder.mutex.RUnlock()
|
||||||
@ -135,6 +140,7 @@ func (t *Tracker) KillQualityIfDead(path string, quality Quality) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Printf("Nobody is watching quality %s of %s. Killing it", quality, path)
|
||||||
t.transcoder.mutex.RLock()
|
t.transcoder.mutex.RLock()
|
||||||
stream := t.transcoder.streams[path]
|
stream := t.transcoder.streams[path]
|
||||||
t.transcoder.mutex.RUnlock()
|
t.transcoder.mutex.RUnlock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user