Skip to content

Commit

Permalink
Check if memory locking should be done before locking unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-j-h authored and TheMarex committed Oct 19, 2015
1 parent 993321e commit 78283a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions routed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ int main(int argc, const char *argv[]) try
{
explicit MemoryLocker(bool shouldLock_) : shouldLock(shouldLock_)
{
if (-1 == mlockall(MCL_CURRENT | MCL_FUTURE))
if (shouldLock && -1 == mlockall(MCL_CURRENT | MCL_FUTURE))
{
couldLock = false;
SimpleLogger().Write(logWARNING) << "memory could not be locked to RAM";
}
}
~MemoryLocker()
{
if (couldLock)
if (shouldLock && couldLock)
(void)munlockall();
}
bool shouldLock = false, couldLock = true;
Expand Down

0 comments on commit 78283a0

Please sign in to comment.