[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH hurd 9/9] boot: improve the demuxer
From: |
Samuel Thibault |
Subject: |
Re: [PATCH hurd 9/9] boot: improve the demuxer |
Date: |
Fri, 7 Nov 2014 19:11:16 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Fri 07 Nov 2014 17:32:02 +0100, a écrit :
> 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.
Ack.
> ---
> 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);
> }
>
>
> --
> 2.1.1
>
--
Samuel
$ du temp.iso
2,0T temp.iso
$ ls temp.iso -l
-r-xr-xr-x 1 samy thibault 16E 2003-03-22 14:44 temp.iso*
-+- je vous dirai pas la marque de mon disque dur, na :p -+-
- Re: [PATCH hurd 4/9] boot: drop bootstrap compat code, (continued)
- [PATCH hurd 5/9] boot: remove unused function `boot_script_read_file', Justus Winter, 2014/11/07
- [PATCH hurd 6/9] boot: drop obsolete device procedures, Justus Winter, 2014/11/07
- [PATCH hurd 7/9] boot: support ds_device_get_status with flavor DEV_GET_RECORDS, Justus Winter, 2014/11/07
- [PATCH hurd 8/9] boot: implement pseudo-time device, Justus Winter, 2014/11/07
- [PATCH hurd 9/9] boot: improve the demuxer, Justus Winter, 2014/11/07
- Re: [PATCH hurd 9/9] boot: improve the demuxer,
Samuel Thibault <=
- Re: [PATCH hurd 1/9] Makeconf: handle the gnumach protocol, Samuel Thibault, 2014/11/20