summaryrefslogtreecommitdiff
path: root/debian/patches/translators-list0002-libfshelp-acquire-references-to-control-ports.patch
blob: bd906408bbe46335e5b71ce5be5d4992cd18ad87 (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
From 271da35911f35184cc0f3d77321794cf680cf6b6 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Fri, 20 Nov 2015 12:46:56 +0100
Subject: [PATCH hurd 2/5] libfshelp: acquire references to control ports

* libfshelp/translator-list.c (translator_ihash_cleanup): Release reference.
(fshelp_set_active_translator): Acquire reference
---
 libfshelp/translator-list.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c
index c87bbaa..87d7f6a 100644
--- a/libfshelp/translator-list.c
+++ b/libfshelp/translator-list.c
@@ -49,12 +49,13 @@ static pthread_mutex_t translator_ihash_lock = PTHREAD_MUTEX_INITIALIZER;
 static void
 translator_ihash_cleanup (void *element, void *arg)
 {
+  error_t err;
   struct translator *translator = element;
 
   if (translator->pi)
     ports_port_deref (translator->pi);
-  /* No need to deallocate translator->active, we only keep the name of
-     the port, not a reference.  */
+  err = mach_port_deallocate (mach_task_self (), translator->active);
+  assert_perror (err);
   free (translator->name);
   free (translator);
 }
@@ -124,8 +125,14 @@ fshelp_set_active_translator (struct port_info *pi,
 	  t->pi = pi;
 	}
 
-      /* No need to increment the reference count, we only keep the
-	 name, not a reference.  */
+      if (MACH_PORT_VALID (t->active))
+	{
+	  err = mach_port_deallocate (mach_task_self (), t->active);
+	  assert_perror (err);
+	}
+      err = mach_port_mod_refs (mach_task_self (), active,
+				MACH_PORT_RIGHT_SEND, +1);
+      assert_perror (err);
       t->active = active;
     }
   else
@@ -143,6 +150,7 @@ error_t
 fshelp_remove_active_translator (mach_port_t active)
 {
   error_t err = 0;
+
   pthread_mutex_lock (&translator_ihash_lock);
 
   struct translator *t = NULL;
-- 
2.1.4