Enhanced newObjectLayerFn (#3837)

master
Zejun Li 8 years ago committed by Harshavardhana
parent 98d17d2a97
commit 32d0d3d4ac
  1. 4
      cmd/object-api-common.go
  2. 9
      cmd/routers.go

@ -38,14 +38,14 @@ const (
)
// Global object layer mutex, used for safely updating object layer.
var globalObjLayerMutex *sync.Mutex
var globalObjLayerMutex *sync.RWMutex
// Global object layer, only accessed by newObjectLayerFn().
var globalObjectAPI ObjectLayer
func init() {
// Initialize this once per server initialization.
globalObjLayerMutex = &sync.Mutex{}
globalObjLayerMutex = &sync.RWMutex{}
}
// Check if the disk is remote.

@ -22,10 +22,11 @@ import (
router "github.com/gorilla/mux"
)
func newObjectLayerFn() ObjectLayer {
globalObjLayerMutex.Lock()
defer globalObjLayerMutex.Unlock()
return globalObjectAPI
func newObjectLayerFn() (layer ObjectLayer) {
globalObjLayerMutex.RLock()
layer = globalObjectAPI
globalObjLayerMutex.RUnlock()
return
}
// Composed function registering routers for only distributed XL setup.

Loading…
Cancel
Save