Check if memory locking should be done before locking unconditionally
This commit is contained in:
parent
993321e971
commit
78283a0e0e
@ -93,7 +93,7 @@ int main(int argc, const char *argv[]) try
|
|||||||
{
|
{
|
||||||
explicit MemoryLocker(bool shouldLock_) : shouldLock(shouldLock_)
|
explicit MemoryLocker(bool shouldLock_) : shouldLock(shouldLock_)
|
||||||
{
|
{
|
||||||
if (-1 == mlockall(MCL_CURRENT | MCL_FUTURE))
|
if (shouldLock && -1 == mlockall(MCL_CURRENT | MCL_FUTURE))
|
||||||
{
|
{
|
||||||
couldLock = false;
|
couldLock = false;
|
||||||
SimpleLogger().Write(logWARNING) << "memory could not be locked to RAM";
|
SimpleLogger().Write(logWARNING) << "memory could not be locked to RAM";
|
||||||
@ -101,7 +101,7 @@ int main(int argc, const char *argv[]) try
|
|||||||
}
|
}
|
||||||
~MemoryLocker()
|
~MemoryLocker()
|
||||||
{
|
{
|
||||||
if (couldLock)
|
if (shouldLock && couldLock)
|
||||||
(void)munlockall();
|
(void)munlockall();
|
||||||
}
|
}
|
||||||
bool shouldLock = false, couldLock = true;
|
bool shouldLock = false, couldLock = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user