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