Przeglądaj źródła

main: Print open file limits

Xenofon Karamanos 8 miesięcy temu
rodzic
commit
4a335848f1
1 zmienionych plików z 11 dodań i 0 usunięć
  1. 11 0
      src/main.c

+ 11 - 0
src/main.c

@@ -59,6 +59,7 @@
 #include <sys/utsname.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <sys/resource.h> /* getrlimit */
 #include <fcntl.h>
 #include <sys/time.h>
 #include <sys/wait.h>
@@ -2209,6 +2210,7 @@ int main(int argc, char **argv)
 	char *tbuf_tmp;
 	struct stat st = {0};
 	long l1 = 0;
+	struct rlimit lim;
 
 	int option_index = 0;
 
@@ -3310,7 +3312,16 @@ int main(int argc, char **argv)
 			fprintf(stderr, "ERROR: error could not increase file limits\n");
 			goto error;
 		}
+	} else {
+		if(getrlimit(RLIMIT_NOFILE, &lim) < 0) {
+			LM_CRIT("cannot get the maximum number of file descriptors: %s\n",
+					strerror(errno));
+			goto error;
+		}
+		LM_INFO("current open file limits [soft/hard]: [%lu/%lu]\n",
+				(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max);
 	}
+
 	if(mlock_pages)
 		mem_lock_pages();