bump reva

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2023-06-16 15:08:10 +02:00
parent 99559f5ea2
commit 48325b9991
8 changed files with 31 additions and 82 deletions
@@ -43,8 +43,7 @@ const tracerName = "providercache"
// Cache holds share information structured by provider and space
type Cache struct {
lockMapLock sync.Mutex
lockMap map[string]*sync.Mutex
lockMap sync.Map
Providers map[string]*Spaces
@@ -106,16 +105,9 @@ func (s *Shares) UnmarshalJSON(data []byte) error {
// LockSpace locks the cache for a given space and returns an unlock function
func (c *Cache) LockSpace(spaceID string) func() {
lock := c.lockMap[spaceID]
if lock == nil {
c.lockMapLock.Lock()
lock = c.lockMap[spaceID]
if lock == nil {
c.lockMap[spaceID] = &sync.Mutex{}
lock = c.lockMap[spaceID]
}
c.lockMapLock.Unlock()
}
v, _ := c.lockMap.LoadOrStore(spaceID, &sync.Mutex{})
lock := v.(*sync.Mutex)
lock.Lock()
return func() { lock.Unlock() }
}
@@ -126,7 +118,7 @@ func New(s metadata.Storage, ttl time.Duration) Cache {
Providers: map[string]*Spaces{},
storage: s,
ttl: ttl,
lockMap: map[string]*sync.Mutex{},
lockMap: sync.Map{},
}
}
@@ -44,8 +44,7 @@ const tracerName = "receivedsharecache"
// It functions as an in-memory cache with a persistence layer
// The storage is sharded by user
type Cache struct {
lockMapLock sync.Mutex
lockMap map[string]*sync.Mutex
lockMap sync.Map
ReceivedSpaces map[string]*Spaces
@@ -79,21 +78,14 @@ func New(s metadata.Storage, ttl time.Duration) Cache {
ReceivedSpaces: map[string]*Spaces{},
storage: s,
ttl: ttl,
lockMap: map[string]*sync.Mutex{},
lockMap: sync.Map{},
}
}
func (c *Cache) lockUser(userID string) func() {
lock := c.lockMap[userID]
if lock == nil {
c.lockMapLock.Lock()
lock = c.lockMap[userID]
if lock == nil {
c.lockMap[userID] = &sync.Mutex{}
lock = c.lockMap[userID]
}
c.lockMapLock.Unlock()
}
v, _ := c.lockMap.LoadOrStore(userID, &sync.Mutex{})
lock := v.(*sync.Mutex)
lock.Lock()
return func() { lock.Unlock() }
}
@@ -43,8 +43,7 @@ const tracerName = "sharecache"
// It functions as an in-memory cache with a persistence layer
// The storage is sharded by user/group
type Cache struct {
lockMapLock sync.Mutex
lockMap map[string]*sync.Mutex
lockMap sync.Map
UserShares map[string]*UserShareCache
@@ -69,16 +68,9 @@ type SpaceShareIDs struct {
}
func (c *Cache) lockUser(userID string) func() {
lock := c.lockMap[userID]
if lock == nil {
c.lockMapLock.Lock()
lock = c.lockMap[userID]
if lock == nil {
c.lockMap[userID] = &sync.Mutex{}
lock = c.lockMap[userID]
}
c.lockMapLock.Unlock()
}
v, _ := c.lockMap.LoadOrStore(userID, &sync.Mutex{})
lock := v.(*sync.Mutex)
lock.Lock()
return func() { lock.Unlock() }
}
@@ -91,7 +83,7 @@ func New(s metadata.Storage, namespace, filename string, ttl time.Duration) Cach
namespace: namespace,
filename: filename,
ttl: ttl,
lockMap: map[string]*sync.Mutex{},
lockMap: sync.Map{},
}
}