0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05: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:
Ramkumar Chinchani 2020-03-20 10:56:19 -07:00
parent 2fd87b6a86
commit dfe023225f
3 changed files with 6 additions and 5 deletions

View file

@ -1362,8 +1362,8 @@ go_repository(
go_repository(
name = "com_github_opensuse_umoci",
importpath = "github.com/openSUSE/umoci",
sum = "h1:MZgFLy5Jl3VKe5uEOU9c25FoySbx3vUXeXLw4Jf6aRs=",
version = "v0.4.5",
sum = "h1:/8Yu54FufyHHQgIZ/wLy+BLQyzk0gbOG24xf5suWOOI=",
version = "v0.4.6-0.20200320140503-9aa268eeb258",
)
go_repository(

View file

@ -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)

View file

@ -148,7 +148,6 @@ func TestAPIs(t *testing.T) {
_, _, _, err = il.GetImageManifest("test", d.String())
So(err, ShouldNotBeNil)
})
})
err = il.DeleteBlobUpload("test", v)