From c41ebf75359c45d96ead0fb3c8fe35b72e902b5a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 14 May 2015 19:05:32 -0700 Subject: [PATCH] Fixing a race in NewMultipartUpload() session for simultaneous requests, observed at play.minio.io --- pkg/storage/drivers/memory/memory.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/storage/drivers/memory/memory.go b/pkg/storage/drivers/memory/memory.go index c12e5aa86..260bd6648 100644 --- a/pkg/storage/drivers/memory/memory.go +++ b/pkg/storage/drivers/memory/memory.go @@ -334,6 +334,7 @@ func (memory *memoryDriver) CreateBucket(bucketName, acl string) error { } var newBucket = storedBucket{} newBucket.objectMetadata = make(map[string]drivers.ObjectMetadata) + newBucket.multiPartSession = make(map[string]multiPartSession) newBucket.bucketMetadata = drivers.BucketMetadata{} newBucket.bucketMetadata.Name = bucketName newBucket.bucketMetadata.Created = time.Now().UTC() @@ -540,13 +541,11 @@ func (memory *memoryDriver) NewMultipartUpload(bucket, key, contentType string) uploadIDSum := sha512.Sum512(id) uploadID := base64.URLEncoding.EncodeToString(uploadIDSum[:])[:47] - storedBucket.multiPartSession = make(map[string]multiPartSession) - storedBucket.multiPartSession[key] = multiPartSession{ + memory.storedBuckets[bucket].multiPartSession[key] = multiPartSession{ uploadID: uploadID, initiated: time.Now(), totalParts: 0, } - memory.storedBuckets[bucket] = storedBucket memory.lock.Unlock() return uploadID, nil