[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 29/64: boot: improve the demuxer
From: |
Samuel Thibault |
Subject: |
[hurd] 29/64: boot: improve the demuxer |
Date: |
Wed, 10 Dec 2014 15:17:05 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 25fe9cb62331d609b87b9d0b1db06d06ab825d16
Author: Justus Winter <address@hidden>
Date: Fri Nov 7 10:43:47 2014 +0100
boot: 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.
* boot/boot.c (mig_reply_setup): Provide local version.
(request_server): Rename to `boot_demuxer', and improve the dispatch.
---
boot/boot.c | 67 ++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 18 deletions(-)
diff --git a/boot/boot.c b/boot/boot.c
index 747ab73..e2cb907 100644
--- a/boot/boot.c
+++ b/boot/boot.c
@@ -169,22 +169,55 @@ useropen (const char *name, int flags, int mode)
return open (name, flags, mode);
}
-int
-request_server (mach_msg_header_t *inp,
- mach_msg_header_t *outp)
-{
- extern int io_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int device_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int notify_server (mach_msg_header_t *, mach_msg_header_t *);
- 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 bootstrap_server (mach_msg_header_t *, mach_msg_header_t *);
+/* XXX: glibc should provide mig_reply_setup but does not. */
+/* Fill in default response. */
+void
+mig_reply_setup (
+ const mach_msg_header_t *in,
+ mach_msg_header_t *out)
+{
+ static const mach_msg_type_t RetCodeType = {
+ /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32,
+ /* msgt_size = */ 32,
+ /* msgt_number = */ 1,
+ /* msgt_inline = */ TRUE,
+ /* msgt_longform = */ FALSE,
+ /* msgt_deallocate = */ FALSE,
+ /* msgt_unused = */ 0
+ };
+
+#define InP (in)
+#define OutP ((mig_reply_header_t *) out)
+ OutP->Head.msgh_bits =
+ MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(InP->msgh_bits), 0);
+ OutP->Head.msgh_size = sizeof *OutP;
+ OutP->Head.msgh_remote_port = InP->msgh_remote_port;
+ OutP->Head.msgh_local_port = MACH_PORT_NULL;
+ OutP->Head.msgh_seqno = 0;
+ OutP->Head.msgh_id = InP->msgh_id + 100;
+ OutP->RetCodeType = RetCodeType;
+ OutP->RetCode = MIG_BAD_ID;
+#undef InP
+#undef OutP
+}
- return (io_server (inp, outp)
- || device_server (inp, outp)
- || notify_server (inp, outp)
- || term_server (inp, outp)
- /* || tioctl_server (inp, outp) */);
+int
+boot_demuxer (mach_msg_header_t *inp,
+ mach_msg_header_t *outp)
+{
+ mig_routine_t routine;
+ mig_reply_setup (inp, outp);
+ if ((routine = io_server_routine (inp)) ||
+ (routine = device_server_routine (inp)) ||
+ (routine = notify_server_routine (inp)) ||
+ (routine = term_server_routine (inp))
+ /* (routine = tioctl_server_routine (inp)) */)
+ {
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
vm_address_t
@@ -710,15 +743,13 @@ main (int argc, char **argv, char **envp)
else /* We hosed */
error (5, errno, "select");
}
-
-/* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */
}
void *
msg_thread (void *arg)
{
while (1)
- mach_msg_server (request_server, 0, receive_set);
+ mach_msg_server (boot_demuxer, 0, receive_set);
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 12/64: trans/mtab: avoid firmlink loops, (continued)
- [hurd] 12/64: trans/mtab: avoid firmlink loops, Samuel Thibault, 2014/12/10
- [hurd] 15/64: startup: rename /hurd/init to /hurd/startup, Samuel Thibault, 2014/12/10
- [hurd] 11/64: Always canonicalize fstab entries with realpath, Samuel Thibault, 2014/12/10
- [hurd] 23/64: startup: also open `console' for reading, Samuel Thibault, 2014/12/10
- [hurd] 26/64: boot: drop obsolete device procedures, Samuel Thibault, 2014/12/10
- [hurd] 16/64: init: add a minimalist init program, Samuel Thibault, 2014/12/10
- [hurd] 22/64: proc: gracefully handle failure to increase priority, Samuel Thibault, 2014/12/10
- [hurd] 25/64: boot: remove unused function `boot_script_read_file', Samuel Thibault, 2014/12/10
- [hurd] 31/64: libdiskfs: fix fabrication of protid, Samuel Thibault, 2014/12/10
- [hurd] 17/64: startup: do not pass signals on to the child, Samuel Thibault, 2014/12/10
- [hurd] 29/64: boot: improve the demuxer,
Samuel Thibault <=
- [hurd] 14/64: procfs: do not hard-code the default argument values, Samuel Thibault, 2014/12/10
- [hurd] 32/64: Fix proc crashes, Samuel Thibault, 2014/12/10
- [hurd] 13/64: Add proc_set_init_task, make runsystem pid 1, Samuel Thibault, 2014/12/10
- [hurd] 40/64: libnetfs: add a payload-aware intrans function, Samuel Thibault, 2014/12/10
- [hurd] 21/64: Makeconf: handle the gnumach protocol, Samuel Thibault, 2014/12/10
- [hurd] 39/64: libdiskfs: add payload-aware intrans functions, Samuel Thibault, 2014/12/10
- [hurd] 18/64: startup: be more specific in the shutdown message, Samuel Thibault, 2014/12/10
- [hurd] 42/64: libpager: add a payload-aware intrans function, Samuel Thibault, 2014/12/10
- [hurd] 19/64: startup: fix the declaration of the *_server functions, Samuel Thibault, 2014/12/10
- [hurd] 43/64: libcons: add a payload-aware intrans function, Samuel Thibault, 2014/12/10