Don't ever print RLIM_INFINITY in a confusing way

This commit is contained in:
Robert Muir 2015-05-30 11:49:44 -04:00
parent b7163c4a71
commit a95528e247
2 changed files with 12 additions and 1 deletions

View File

@ -39,6 +39,7 @@ final class JNACLibrary {
public static final int MCL_CURRENT = 1;
public static final int ENOMEM = 12;
public static final int RLIMIT_MEMLOCK = Constants.MAC_OS_X ? 6 : 8;
public static final long RLIM_INFINITY = Constants.MAC_OS_X ? 9223372036854775807L : -1L;
static {
try {

View File

@ -75,13 +75,23 @@ class JNANatives {
logger.warn("Unable to lock JVM Memory: error=" + errno + ",reason=" + errMsg + ". This can result in part of the JVM being swapped out");
if (errno == JNACLibrary.ENOMEM) {
if (rlimitSuccess) {
logger.warn("Increase RLIMIT_MEMLOCK (ulimit). soft limit:" + softLimit + ", hard limit:" + hardLimit);
logger.warn("Increase RLIMIT_MEMLOCK (ulimit). soft limit: " + rlimitToString(softLimit) + ", hard limit: " + rlimitToString(hardLimit));
} else {
logger.warn("Increase RLIMIT_MEMLOCK (ulimit).");
}
}
}
static String rlimitToString(long value) {
assert Constants.LINUX || Constants.MAC_OS_X;
if (value == JNACLibrary.RLIM_INFINITY) {
return "unlimited";
} else {
// TODO, on java 8 use Long.toUnsignedString, since thats what it is.
return Long.toString(value);
}
}
/** Returns true if user is root, false if not, or if we don't know */
static boolean definitelyRunningAsRoot() {
if (Constants.WINDOWS) {