mirror of
https://github.com/minio/minio.git
synced 2025-04-11 23:12:12 -04:00
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.
|
// 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().
|
// Global object layer, only accessed by newObjectLayerFn().
|
||||||
var globalObjectAPI ObjectLayer
|
var globalObjectAPI ObjectLayer
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Initialize this once per server initialization.
|
// Initialize this once per server initialization.
|
||||||
globalObjLayerMutex = &sync.Mutex{}
|
globalObjLayerMutex = &sync.RWMutex{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the disk is remote.
|
// Check if the disk is remote.
|
||||||
|
@ -22,10 +22,11 @@ import (
|
|||||||
router "github.com/gorilla/mux"
|
router "github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newObjectLayerFn() ObjectLayer {
|
func newObjectLayerFn() (layer ObjectLayer) {
|
||||||
globalObjLayerMutex.Lock()
|
globalObjLayerMutex.RLock()
|
||||||
defer globalObjLayerMutex.Unlock()
|
layer = globalObjectAPI
|
||||||
return globalObjectAPI
|
globalObjLayerMutex.RUnlock()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Composed function registering routers for only distributed XL setup.
|
// Composed function registering routers for only distributed XL setup.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user