mirror of https://github.com/minio/minio.git
Enhanced newObjectLayerFn (#3837)
This commit is contained in:
parent
98d17d2a97
commit
32d0d3d4ac
|
@ -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…
Reference in New Issue