summaryrefslogtreecommitdiff
path: root/debian/patches/0001-term-improve-the-demuxer.patch
blob: 9b0e3c0efc82eadb12f3203221a18181dd9cc488 (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
From 7092a17e6c503c7843618e9f1118c55359c79f2e Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Tue, 10 Jun 2014 14:49:46 +0200
Subject: [PATCH 1/3] term: improve the demuxer

Handle multiple request types as recommended by the Mach Server
Writer's Guide section 4, subsection "Handling Multiple Request
Types".  This avoids initializing the reply message in every X_server
function.

* term/main.c (demuxer): Improve the demuxer function.
---
 term/main.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/term/main.c b/term/main.c
index 9cc32d4..be014e1 100644
--- a/term/main.c
+++ b/term/main.c
@@ -32,6 +32,10 @@
 
 #include <version.h>
 
+#include "term_S.h"
+#include "tioctl_S.h"
+#include "device_reply_S.h"
+
 const char *argp_program_version = STANDARD_HURD_VERSION (term);
 
 int trivfs_fstype = FSTYPE_TERM;
@@ -61,14 +65,18 @@ dev_t rdev;
 int
 demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
 {
-  extern int term_server (mach_msg_header_t *, mach_msg_header_t *);
-  extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *);
-  extern int device_reply_server (mach_msg_header_t *, mach_msg_header_t *);
-
-  return (trivfs_demuxer (inp, outp)
-	  || term_server (inp, outp)
-	  || tioctl_server (inp, outp)
-	  || device_reply_server (inp, outp));
+  mig_routine_t routine;
+  if ((routine = NULL, trivfs_demuxer (inp, outp)) ||
+      (routine = term_server_routine (inp)) ||
+      (routine = tioctl_server_routine (inp)) ||
+      (routine = device_reply_server_routine (inp)))
+    {
+      if (routine)
+        (*routine) (inp, outp);
+      return TRUE;
+    }
+  else
+    return FALSE;
 }
 
 static struct argp_option options[] =
-- 
2.0.0