fs: Add granular locking.

This commit is contained in:
Harshavardhana
2016-02-04 20:40:58 -08:00
parent f2113d35be
commit 8557cbc9b7
9 changed files with 196 additions and 159 deletions

View File

@@ -18,8 +18,8 @@ package fs
// IsPrivateBucket - is private bucket
func (fs Filesystem) IsPrivateBucket(bucket string) bool {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.rwLock.Lock()
defer fs.rwLock.Unlock()
bucketMetadata, ok := fs.buckets.Metadata[bucket]
if !ok {
return true
@@ -29,8 +29,8 @@ func (fs Filesystem) IsPrivateBucket(bucket string) bool {
// IsPublicBucket - is public bucket
func (fs Filesystem) IsPublicBucket(bucket string) bool {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.rwLock.Lock()
defer fs.rwLock.Unlock()
bucketMetadata, ok := fs.buckets.Metadata[bucket]
if !ok {
return true
@@ -40,8 +40,8 @@ func (fs Filesystem) IsPublicBucket(bucket string) bool {
// IsReadOnlyBucket - is read only bucket
func (fs Filesystem) IsReadOnlyBucket(bucket string) bool {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.rwLock.Lock()
defer fs.rwLock.Unlock()
bucketMetadata, ok := fs.buckets.Metadata[bucket]
if !ok {
return true