Skip to content

Commit 0571911

Browse files
authored
fix deadlock (#885)
Signed-off-by: James Ranson <[email protected]>
1 parent f304fcd commit 0571911

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/proxy/engines/objectproxycache.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,13 @@ func fetchViaObjectProxyCache(w io.Writer, r *http.Request) (*http.Response, sta
448448
if !rsc.NoLock {
449449
pr.cacheLock, _ = cc.Locker().RAcquire(pr.key)
450450
pr.hasReadLock = true
451+
defer func() {
452+
if pr.hasWriteLock {
453+
pr.cacheLock.Release()
454+
} else if pr.hasReadLock {
455+
pr.cacheLock.RRelease()
456+
}
457+
}()
451458
}
452459

453460
var err error
@@ -473,12 +480,6 @@ func fetchViaObjectProxyCache(w io.Writer, r *http.Request) (*http.Response, sta
473480
}
474481
}
475482

476-
if pr.hasWriteLock {
477-
pr.cacheLock.Release()
478-
} else if pr.hasReadLock {
479-
pr.cacheLock.RRelease()
480-
}
481-
482483
if pr.wasReran {
483484
return nil, status.LookupStatusRevalidated
484485
}

0 commit comments

Comments
 (0)