diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index df4fdb016..9817d363a 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -220,6 +220,8 @@ func StartGateway(ctx *cli.Context, gw Gateway) { logger.FatalIf(err, "Unable to initialize gateway backend") } + newObject = NewGatewayLayerWithLocker(newObject) + // Re-enable logging logger.Disable = false diff --git a/cmd/gateway-unsupported.go b/cmd/gateway-unsupported.go index 24a6be762..03024c824 100644 --- a/cmd/gateway-unsupported.go +++ b/cmd/gateway-unsupported.go @@ -26,6 +26,22 @@ import ( "github.com/minio/minio/pkg/policy" ) +// GatewayLocker implements custom NeNSLock implementation +type GatewayLocker struct { + ObjectLayer + nsMutex *nsLockMap +} + +// NewNSLock - implements gateway level locker +func (l *GatewayLocker) NewNSLock(ctx context.Context, bucket string, object string) RWLocker { + return l.nsMutex.NewNSLock(ctx, nil, bucket, object) +} + +// NewGatewayLayerWithLocker - initialize gateway with locker. +func NewGatewayLayerWithLocker(gwLayer ObjectLayer) ObjectLayer { + return &GatewayLocker{ObjectLayer: gwLayer, nsMutex: newNSLock(false)} +} + // GatewayUnsupported list of unsupported call stubs for gateway. type GatewayUnsupported struct{}