aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-08-24 07:46:51 -0400
committerJack Lloyd <[email protected]>2015-08-24 07:46:51 -0400
commitce849c364c29ce020369685ce8d221f8e67cf538 (patch)
tree019731a15df0d7f09fbd567254bd5e9e5a1affd8 /src
parent97b6e192e752fe8a0fd95116a84d7b29d8ed71f5 (diff)
Guard rlimit reset with a defined check for RLIMIT_MEMLOCK as it is
missing on Solaris at least. On such systems it's probably safe to assume that no amount of memory can be mlock'ed from userspace, so just return zero to disable the allocator entirely. GH #262
Diffstat (limited to 'src')
-rw-r--r--src/lib/alloc/locking_allocator/locking_allocator.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/alloc/locking_allocator/locking_allocator.cpp b/src/lib/alloc/locking_allocator/locking_allocator.cpp
index 6a9cc2579..ec294d8f0 100644
--- a/src/lib/alloc/locking_allocator/locking_allocator.cpp
+++ b/src/lib/alloc/locking_allocator/locking_allocator.cpp
@@ -26,7 +26,9 @@ const size_t ALIGNMENT_MULTIPLE = 2;
size_t reset_mlock_limit(size_t max_req)
{
+#if defined(RLIMIT_MEMLOCK)
struct rlimit limits;
+
::getrlimit(RLIMIT_MEMLOCK, &limits);
if(limits.rlim_cur < limits.rlim_max)
@@ -37,6 +39,9 @@ size_t reset_mlock_limit(size_t max_req)
}
return std::min<size_t>(limits.rlim_cur, max_req);
+#endif
+
+ return 0;
}
size_t mlock_limit()