]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Remove the request for current memlock limits
authorSebastian Hahn <sebastian@torproject.org>
Sun, 3 Jan 2010 18:58:28 +0000 (19:58 +0100)
committerSebastian Hahn <sebastian@torproject.org>
Sun, 28 Feb 2010 13:48:47 +0000 (14:48 +0100)
The getrlimit call didn't have any effect. Also make some logging
less verbose on default log level, and refactor a bit.

src/common/compat.c

index 7f53704c6905e089a4fbbf4a6a7e5277d4c33f15..0c6eb150b7c92765f0aae97e690b9102e7c06394 100644 (file)
@@ -2187,30 +2187,18 @@ tor_set_max_memlock(void)
    */
 
   struct rlimit limit;
-  int ret;
-
-  /* Do we want to report current limits first? This is not really needed. */
-  ret = getrlimit(RLIMIT_MEMLOCK, &limit);
-  if (ret == -1) {
-    log_warn(LD_GENERAL, "Could not get RLIMIT_MEMLOCK: %s", strerror(errno));
-    return -1;
-  }
 
   /* RLIM_INFINITY is -1 on some platforms. */
   limit.rlim_cur = RLIM_INFINITY;
   limit.rlim_max = RLIM_INFINITY;
 
-  ret = setrlimit(RLIMIT_MEMLOCK, &limit);
-  if (ret == -1) {
+  if (setrlimit(RLIMIT_MEMLOCK, &limit) == -1) {
     if (errno == EPERM) {
       log_warn(LD_GENERAL, "You appear to lack permissions to change memory "
                            "limits. Are you root?");
-      log_warn(LD_GENERAL, "Unable to raise RLIMIT_MEMLOCK: %s",
-               strerror(errno));
-    } else {
-      log_warn(LD_GENERAL, "Could not raise RLIMIT_MEMLOCK: %s",
-               strerror(errno));
     }
+    log_warn(LD_GENERAL, "Unable to raise RLIMIT_MEMLOCK: %s",
+             strerror(errno));
     return -1;
   }
 
@@ -2243,12 +2231,11 @@ tor_mlockall(void)
 
 #if defined(HAVE_MLOCKALL) && HAVE_DECL_MLOCKALL && defined(RLIMIT_MEMLOCK)
   if (tor_set_max_memlock() == 0) {
-    /* Perhaps we only want to log this if we're in a verbose mode? */
-    log_notice(LD_GENERAL, "RLIMIT_MEMLOCK is now set to RLIM_INFINITY.");
+    log_debug(LD_GENERAL, "RLIMIT_MEMLOCK is now set to RLIM_INFINITY.");
   }
 
   if (mlockall(MCL_CURRENT|MCL_FUTURE) == 0) {
-    log_notice(LD_GENERAL, "Insecure OS paging is effectively disabled.");
+    log_info(LD_GENERAL, "Insecure OS paging is effectively disabled.");
     return 0;
   } else {
     if (errno == ENOSYS) {