diff --git a/restream/core.go b/restream/core.go index 1286e57d..d8895c2e 100644 --- a/restream/core.go +++ b/restream/core.go @@ -1167,7 +1167,6 @@ func (r *restream) UpdateProcess(id app.ProcessID, config *app.Config, force boo if !ok { return ErrUnknownProcess } - defer r.tasks.Unlock(id) err := r.updateProcess(task, config, force) @@ -1305,11 +1304,10 @@ func (r *restream) DeleteProcess(id app.ProcessID) error { if !ok { return ErrUnknownProcess } + defer r.tasks.Unlock(id) err := r.deleteProcess(task) - r.tasks.Unlock(id) - if err != nil { return err } @@ -1414,11 +1412,10 @@ func (r *restream) ReloadProcess(id app.ProcessID) error { if !ok { return ErrUnknownProcess } + defer r.tasks.Unlock(id) err := r.reloadProcess(task) - r.tasks.Unlock(id) - if err != nil { return err } @@ -1607,11 +1604,10 @@ func (r *restream) ReloadSkills() error { } func (r *restream) GetPlayout(id app.ProcessID, inputid string) (string, error) { - task, ok := r.tasks.LoadAndRLock(id) + task, ok := r.tasks.LoadUnsafe(id) if !ok { return "", ErrUnknownProcess } - defer r.tasks.RUnlock(id) port, ok := task.playout[inputid] if !ok { diff --git a/restream/manager.go b/restream/manager.go index 736c0476..e77df05c 100644 --- a/restream/manager.go +++ b/restream/manager.go @@ -84,6 +84,8 @@ func (m *Storage) Has(id app.ProcessID) bool { return hasTask } +// LoadUnsafe returns the value stored in the map for a key, or zero value of type V if no value is present. +// The ok result indicates whether value was found in the map. func (m *Storage) LoadUnsafe(id app.ProcessID) (*task, bool) { mt, ok := m.tasks.Load(id) if !ok { @@ -93,28 +95,6 @@ func (m *Storage) LoadUnsafe(id app.ProcessID) (*task, bool) { return mt.task, true } -// LoadAndRLock returns the value stored in the map for a key, or zero value of type V if no value is present. -// The ok result indicates whether value was found in the map. -func (m *Storage) LoadAndRLock(id app.ProcessID) (*task, bool) { - mt, ok := m.tasks.Load(id) - if !ok { - return nil, false - } - - mt.lock.RLock() - - return mt.task, true -} - -func (m *Storage) RUnlock(id app.ProcessID) { - mt, ok := m.tasks.Load(id) - if !ok { - return - } - - mt.lock.RUnlock() -} - func (m *Storage) LoadAndLock(id app.ProcessID) (*task, bool) { mt, ok := m.tasks.Load(id) if !ok {