summaryrefslogtreecommitdiff
path: root/net/xmule/patches/patch-ad
blob: e62eadbd111179064940fadf636dcfe7594cb998 (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
$NetBSD: patch-ad,v 1.2 2003/06/28 10:55:47 jmmv Exp $

--- src/xmule.cpp.orig	2003-06-19 12:04:38.000000000 +0200
+++ src/xmule.cpp
@@ -93,8 +93,10 @@ int CxmuleApp::OnExit() {
   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");
 }
@@ -197,6 +199,28 @@ public:
 
 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
@@ -204,6 +228,8 @@ bool CxmuleApp::OnInit()
 
 	//putenv("LANG=en_US");
 
+	SetResourceLimits();
+
 	// for resources
 	wxFileSystem::AddHandler(new wxZipFSHandler);
 	wxXmlResource::Get()->InitAllHandlers();