aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/locking_allocator
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-25 02:11:10 +0000
committerlloyd <[email protected]>2012-05-25 02:11:10 +0000
commit113f4035f41cf3152832e1753d28b79a7ea811a4 (patch)
tree1e2071c1f7786972d268b727f52ee33225ad68d4 /src/alloc/locking_allocator
parentee42784fee56c48f72ecf03d7b93765dac35edf5 (diff)
For block and stream ciphers, don't set the size of the key vectors
until we are actually setting a key. This avoids the problem of prototype objects consuming not just memory but the precious few bytes of mlock'able memory that we're given by Linux. Use clear_mem instead of a loop in BigInt::mask_bits If OS2ECP encounters an invalid format type, include what type it was in the exception message.
Diffstat (limited to 'src/alloc/locking_allocator')
-rw-r--r--src/alloc/locking_allocator/locking_allocator.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/alloc/locking_allocator/locking_allocator.cpp b/src/alloc/locking_allocator/locking_allocator.cpp
index cb7aab08c..bb1b6abcf 100644
--- a/src/alloc/locking_allocator/locking_allocator.cpp
+++ b/src/alloc/locking_allocator/locking_allocator.cpp
@@ -28,6 +28,14 @@ size_t mlock_limit()
::getrlimit(RLIMIT_MEMLOCK, &limits);
}
+ /*
+ * Linux defaults to only 64 KiB of mlockable memory per process
+ * (too small) but BSDs offer a small fraction of total RAM (more
+ * than we need). Bound the total mlock size to 256 KiB which is
+ * enough to run the entire test suite without spilling to non-mlock
+ * memory, but small enough that we should not cause problems if
+ * multiple processes are mlocking on the same machine.
+ */
return std::min<size_t>(limits.rlim_cur, 256*1024);
}