vault: ability to toggle mlock on core

This commit is contained in:
Mitchell Hashimoto
2015-04-27 16:40:14 -07:00
parent 3a31d7c6f9
commit 4ea2d674c8

View File

@@ -198,6 +198,7 @@ type CoreConfig struct {
Physical physical.Backend Physical physical.Backend
Logger *log.Logger Logger *log.Logger
DisableCache bool // Disables the LRU cache on the physical backend DisableCache bool // Disables the LRU cache on the physical backend
DisableMlock bool // Disables mlock syscall
CacheSize int // Custom cache size of zero for default CacheSize int // Custom cache size of zero for default
AdvertiseAddr string // Set as the leader address for HA AdvertiseAddr string // Set as the leader address for HA
} }
@@ -223,10 +224,12 @@ func NewCore(conf *CoreConfig) (*Core, error) {
} }
} }
if !conf.DisableMlock {
// Ensure our memory usage is locked into physical RAM // Ensure our memory usage is locked into physical RAM
if err := LockMemory(); err != nil { if err := LockMemory(); err != nil {
return nil, fmt.Errorf("failed to lock memory: %v", err) return nil, fmt.Errorf("failed to lock memory: %v", err)
} }
}
// Construct a new AES-GCM barrier // Construct a new AES-GCM barrier
barrier, err := NewAESGCMBarrier(conf.Physical) barrier, err := NewAESGCMBarrier(conf.Physical)