mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix some race conditions
This commit is contained in:
parent
4c7e335ef4
commit
7baa586738
@ -47,4 +47,4 @@ ENV NVIDIA_VISIBLE_DEVICES="all"
|
||||
ENV NVIDIA_DRIVER_CAPABILITIES="all"
|
||||
|
||||
EXPOSE 7666
|
||||
CMD wgo run .
|
||||
CMD wgo run -race .
|
||||
|
@ -54,8 +54,8 @@ func (kf *Keyframe) add(values []float64) {
|
||||
}
|
||||
|
||||
func (kf *Keyframe) AddListener(callback func(keyframes []float64)) {
|
||||
kf.mutex.RLock()
|
||||
defer kf.mutex.RUnlock()
|
||||
kf.mutex.Lock()
|
||||
defer kf.mutex.Unlock()
|
||||
kf.listeners = append(kf.listeners, callback)
|
||||
}
|
||||
|
||||
@ -72,6 +72,7 @@ func GetKeyframes(sha string, path string) *Keyframe {
|
||||
save_path := fmt.Sprintf("%s/%s/keyframes.json", Settings.Metadata, sha)
|
||||
if err := getSavedInfo(save_path, kf); err == nil {
|
||||
log.Printf("Using keyframes cache on filesystem for %s", path)
|
||||
kf.ready.Done()
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -377,6 +377,7 @@ func (ts *Stream) GetSegment(segment int32) (string, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
readyChan := ts.segments[segment].channel
|
||||
ts.lock.RUnlock()
|
||||
|
||||
if !ready {
|
||||
@ -392,7 +393,7 @@ func (ts *Stream) GetSegment(segment int32) (string, error) {
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ts.segments[segment].channel:
|
||||
case <-readyChan:
|
||||
case <-time.After(60 * time.Second):
|
||||
return "", errors.New("could not retrive the selected segment (timeout)")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user