mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
pkg/api: use a rwlock when accessing storage
The original patch used a mutex, however, the workload patterns are likely to be read-heavy, so use a rwlock instead.
This commit is contained in:
+4
-2
@@ -53,7 +53,8 @@ func NewRouteHandler(c *Controller) *RouteHandler {
|
||||
}
|
||||
|
||||
// blobRLockWrapper calls the real handler with read-lock held
|
||||
func (rh *RouteHandler) blobRLockWrapper(f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
func (rh *RouteHandler) blobRLockWrapper(f func(w http.ResponseWriter,
|
||||
r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
rh.blobLock.RLock()
|
||||
f(w, r)
|
||||
@@ -62,7 +63,8 @@ func (rh *RouteHandler) blobRLockWrapper(f func(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
|
||||
// blobLockWrapper calls the real handler with write-lock held
|
||||
func (rh *RouteHandler) blobLockWrapper(f func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
func (rh *RouteHandler) blobLockWrapper(f func(w http.ResponseWriter,
|
||||
r *http.Request)) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
rh.blobLock.Lock()
|
||||
f(w, r)
|
||||
|
||||
@@ -148,7 +148,6 @@ func TestAPIs(t *testing.T) {
|
||||
_, _, _, err = il.GetImageManifest("test", d.String())
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
err = il.DeleteBlobUpload("test", v)
|
||||
|
||||
Reference in New Issue
Block a user