summaryrefslogtreecommitdiff
path: root/net/xmule/patches/patch-ad
blob: 37e18e384f05e3b65fef462a4269e75ec3a8aaa4 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
$NetBSD: patch-ad,v 1.1.1.1 2003/06/03 09:17:21 jmmv Exp $

--- src/xmule.cpp.orig	2003-06-01 19:33:55.000000000 +0000
+++ src/xmule.cpp	2003-06-01 19:34:19.000000000 +0000
@@ -103,8 +103,13 @@
   delete clientlist; 
 #endif
 
-  hashing_mut.Unlock();
-  pendingMutex.Unlock();
+  if (hashing_mut.TryLock() == wxMUTEX_NO_ERROR) {
+    hashing_mut.Unlock();
+  }
+
+  if (pendingMutex.TryLock() == wxMUTEX_NO_ERROR) {
+    pendingMutex.Unlock();
+  }
 
   printf("xMule shutdown completed.\n");
 }
@@ -207,6 +212,28 @@
 
 extern void InitXmlResource();
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+static void UnlimitResource(int resType)
+{
+#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+  struct rlimit rl;
+  getrlimit(resType, &rl);
+  rl.rlim_cur = rl.rlim_max;
+  setrlimit(resType, &rl);
+#endif
+}
+
+static void SetResourceLimits()
+{
+  UnlimitResource(RLIMIT_DATA);
+  UnlimitResource(RLIMIT_FSIZE);
+  UnlimitResource(RLIMIT_NOFILE);
+  UnlimitResource(RLIMIT_RSS);
+}
+
 bool CxmuleApp::OnInit()
 {
 	// catch fatal exceptions
@@ -214,6 +241,8 @@
 
 	//putenv("LANG=en_US");
 
+	SetResourceLimits();
+
 	// for resources
 	wxFileSystem::AddHandler(new wxZipFSHandler);
 	wxXmlResource::Get()->InitAllHandlers();
@@ -641,11 +670,13 @@
     
 } //End Added By Bouc7
 
-
+#if defined(linux)
 #include <execinfo.h>
+#endif
 
 void CxmuleApp::OnFatalException()
 {
+#if defined(linux)
     // (stkn) create backtrace
     void * bt_array[100]; // 100 should be enough ?!?
     char ** bt_strings;
@@ -666,6 +697,7 @@
        fprintf(stderr, "[%d] %s\n", i, bt_strings[i]);
        
     free(bt_strings);
+#endif
 }
 
 #define wxGTK_WINDOW 1