Add setrlimit to increase default fd limit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wine is very, very heavy on file descriptors.  NetBSD, for one, has a
default NOFILE rlimit of 64 -- which is very easy to exhaust in Wine without
repeatedly increasing the limit before running it.

The following patch bumps the soft limit up to the hard limit automatically
during wine_init().  If getrlimit or setrlimit fails, it quietly continues
so as to be nonintrusive.  This patch will require an autoconf regen.

===

Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.175
diff -u -r1.175 configure.ac
--- configure.ac	26 Aug 2003 02:31:43 -0000	1.175
+++ configure.ac	27 Aug 2003 00:30:20 -0000
@@ -1035,6 +1035,7 @@
 	sys/poll.h \
 	sys/ptrace.h \
 	sys/reg.h \
+	sys/resource.h \
 	sys/scsiio.h \
 	sys/shm.h \
 	sys/signal.h \
Index: include/config.h.in
===================================================================
RCS file: /home/wine/wine/include/config.h.in,v
retrieving revision 1.159
diff -u -r1.159 config.h.in
--- include/config.h.in	20 Aug 2003 04:19:01 -0000	1.159
+++ include/config.h.in	27 Aug 2003 00:30:20 -0000
@@ -554,6 +554,9 @@
 /* Define to 1 if you have the <sys/reg.h> header file. */
 #undef HAVE_SYS_REG_H

+/* Define to 1 if you have the <sys/resource.h> header file. */
+#undef HAVE_SYS_RESOURCE_H
+
 /* Define to 1 if you have the <sys/scsiio.h> header file. */
 #undef HAVE_SYS_SCSIIO_H

Index: libs/wine/loader.c
===================================================================
RCS file: /home/wine/wine/libs/wine/loader.c,v
retrieving revision 1.4
diff -u -r1.4 loader.c
--- libs/wine/loader.c	3 Jul 2003 18:23:10 -0000	1.4
+++ libs/wine/loader.c	27 Aug 2003 00:30:20 -0000
@@ -30,6 +30,9 @@
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
@@ -422,6 +425,18 @@
     void *ntdll;
     void (*init_func)(int, char **);

+#ifdef RLIMIT_NOFILE
+    {
+	/* Expand "nofile" rlimit before opening files. */
+	struct rlimit rlim;
+
+	if (!getrlimit(RLIMIT_NOFILE, &rlim)) {
+	    rlim.rlim_cur = rlim.rlim_max;
+	    setrlimit(RLIMIT_NOFILE, &rlim);
+	}
+    }
+#endif
+
     if (!(ntdll = dlopen_dll( "ntdll.dll", error, error_size, 0, &file_exists ))) return;
     if (!(init_func = wine_dlsym( ntdll, "__wine_process_init", error, error_size ))) return;
     init_func( argc, argv );

-- 
-- Todd Vierling <tv@pobox.com>


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux