Fix streaming scenes not able to be deleted (#2549)

* Don't navigate away from scene if delete failed
* Close connection on cancel
This commit is contained in:
WithoutPants
2022-05-04 09:27:22 +10:00
committed by GitHub
parent 0c2dc17e8e
commit e87fd516d6
4 changed files with 46 additions and 3 deletions

View File

@@ -7,6 +7,10 @@ import (
"time"
)
type Cancellable interface {
Cancel()
}
type LockContext struct {
context.Context
cancel context.CancelFunc
@@ -57,6 +61,16 @@ func NewReadLockManager() *ReadLockManager {
func (m *ReadLockManager) ReadLock(ctx context.Context, fn string) *LockContext {
retCtx, cancel := context.WithCancel(ctx)
// if Cancellable, call Cancel() when cancelled
cancellable, ok := ctx.(Cancellable)
if ok {
origCancel := cancel
cancel = func() {
origCancel()
cancellable.Cancel()
}
}
m.mutex.Lock()
defer m.mutex.Unlock()