summaryrefslogtreecommitdiff
path: root/mail/thunderbird10/patches/patch-zc
blob: 5bfb5ff52163eab129e9854fa453e1c34ea4fa8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$NetBSD: patch-zc,v 1.1.1.1 2012/03/15 09:45:29 ryoon Exp $

--- mail/app/nsMailApp.cpp.orig	2012-02-16 10:18:22.000000000 +0000
+++ mail/app/nsMailApp.cpp
@@ -48,6 +48,27 @@
 
 #include <stdio.h>
 #include <stdarg.h>
+#include <sys/resource.h>
+/*
+ * On netbsd-4, ulimit -n is 64 by default; too few for us.
+ */
+static void netbsd_fixrlimit(void) {
+	struct rlimit rlp;
+	if (getrlimit(RLIMIT_NOFILE, &rlp) == -1) {
+		fprintf(stderr, "warning: getrlimit failed\n");
+		return;
+	}
+	if (rlp.rlim_cur >= 512)
+		return;
+	if (rlp.rlim_max < 512) {
+		fprintf(stderr, "warning: hard limit of 'ulimit -n' too low\n");
+		rlp.rlim_cur = rlp.rlim_max;
+	}
+	else
+		rlp.rlim_cur = 512;
+	if (setrlimit(RLIMIT_NOFILE, &rlp) == -1)
+		fprintf(stderr, "warning: setrlimit failed\n");
+}
 
 #include "nsCOMPtr.h"
 #include "nsILocalFile.h"
@@ -147,6 +168,7 @@ static int do_main(const char *exePath, 
 
 int main(int argc, char* argv[])
 {
+  netbsd_fixrlimit();
   char exePath[MAXPATHLEN];
 
   nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath);