]> granicus.if.org Git - curl/commitdiff
Don't abort tests 518 and 537 when unable to raise the open-file soft limit
authorYang Tse <yangsita@gmail.com>
Thu, 17 Jan 2008 18:57:50 +0000 (18:57 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 17 Jan 2008 18:57:50 +0000 (18:57 +0000)
CHANGES
tests/libtest/lib518.c
tests/libtest/lib537.c

diff --git a/CHANGES b/CHANGES
index 89b091ceb4a967e98f5f7f48d7b5ec8d2f62de6c..405655afe923ad061ad8472c60df1ca95852c2ba 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@
 
                                   Changelog
 
+Yang Tse (17 Jan 2008)
+- Don't abort tests 518 and 537 when unable to raise the open-file soft limit.
+
 Daniel S (16 Jan 2008)
 - Nathan Coulter's patch that makes runtests.pl respect the PATH when figuring
   out what valgrind to run.
index 3b83ae37880fcc8a00915be8fbe25d99d852d088..22680688bd9ae0bbf15968fe2bde426dff43a39c 100644 (file)
@@ -153,12 +153,27 @@ static int rlimit(int keep_open)
 
   if (rl.rlim_cur != rl.rlim_max) {
 
+#ifdef OPEN_MAX
+    if ((rl.rlim_cur > 0) &&
+        (rl.rlim_cur < OPEN_MAX)) {
+      fprintf(stderr, "raising soft limit up to OPEN_MAX\n");
+      rl.rlim_cur = OPEN_MAX;
+      if (setrlimit(RLIMIT_NOFILE, &rl) != 0) {
+        /* on failure don't abort just issue a warning */
+        store_errmsg("setrlimit() failed", ERRNO);
+        fprintf(stderr, "%s\n", msgbuff);
+        msgbuff[0] = '\0';
+      }
+    }
+#endif
+
     fprintf(stderr, "raising soft limit up to hard limit\n");
     rl.rlim_cur = rl.rlim_max;
     if (setrlimit(RLIMIT_NOFILE, &rl) != 0) {
+      /* on failure don't abort just issue a warning */
       store_errmsg("setrlimit() failed", ERRNO);
       fprintf(stderr, "%s\n", msgbuff);
-      return -2;
+      msgbuff[0] = '\0';
     }
 
     /* get current open file limits */
index b4b2b7a93645d060a2fcf9a96b1318f1051df5d7..1f5a34221bdb5be058afe635de77c950212ea2bd 100644 (file)
@@ -148,12 +148,27 @@ static int rlimit(int keep_open)
 
   if (rl.rlim_cur != rl.rlim_max) {
 
+#ifdef OPEN_MAX
+    if ((rl.rlim_cur > 0) &&
+        (rl.rlim_cur < OPEN_MAX)) {
+      fprintf(stderr, "raising soft limit up to OPEN_MAX\n");
+      rl.rlim_cur = OPEN_MAX;
+      if (setrlimit(RLIMIT_NOFILE, &rl) != 0) {
+        /* on failure don't abort just issue a warning */
+        store_errmsg("setrlimit() failed", ERRNO);
+        fprintf(stderr, "%s\n", msgbuff);
+        msgbuff[0] = '\0';
+      }
+    }
+#endif
+
     fprintf(stderr, "raising soft limit up to hard limit\n");
     rl.rlim_cur = rl.rlim_max;
     if (setrlimit(RLIMIT_NOFILE, &rl) != 0) {
+      /* on failure don't abort just issue a warning */
       store_errmsg("setrlimit() failed", ERRNO);
       fprintf(stderr, "%s\n", msgbuff);
-      return -2;
+      msgbuff[0] = '\0';
     }
 
     /* get current open file limits */