[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/7] pfinet: improve the pfinet_demuxer function
From: |
Justus Winter |
Subject: |
[PATCH 6/7] pfinet: improve the pfinet_demuxer function |
Date: |
Sat, 30 Nov 2013 20:11:02 +0100 |
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. The reply message has already been properly initialized in
libports, so there is no need to call mig_reply_setup.
* pfinet/main.c (pfinet_demuxer): Improve the demuxer function.
---
pfinet/main.c | 54 +++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 37 insertions(+), 17 deletions(-)
diff --git a/pfinet/main.c b/pfinet/main.c
index c952719..321edfb 100644
--- a/pfinet/main.c
+++ b/pfinet/main.c
@@ -77,11 +77,13 @@ pfinet_demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
{
struct port_info *pi;
- extern int io_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int socket_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int startup_notify_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int pfinet_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int iioctl_server (mach_msg_header_t *, mach_msg_header_t *);
+ mig_routine_t io_server_routine (mach_msg_header_t *);
+ mig_routine_t socket_server_routine (mach_msg_header_t *);
+ mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *);
+ mig_routine_t ports_notify_server_routine (mach_msg_header_t *);
+ mig_routine_t startup_notify_server_routine (mach_msg_header_t *);
+ mig_routine_t pfinet_server_routine (mach_msg_header_t *);
+ mig_routine_t iioctl_server_routine (mach_msg_header_t *);
/* We have several classes in one bucket, which need to be demuxed
differently. */
@@ -90,20 +92,38 @@ pfinet_demuxer (mach_msg_header_t *inp,
if (pi)
{
ports_port_deref (pi);
-
- return (io_server (inp, outp)
- || socket_server (inp, outp)
- || pfinet_server (inp, outp)
- || iioctl_server (inp, outp)
- || trivfs_demuxer (inp, outp)
- || startup_notify_server (inp, outp));
+
+ mig_routine_t routine;
+ if ((routine = io_server_routine (inp)) ||
+ (routine = socket_server_routine (inp)) ||
+ (routine = pfinet_server_routine (inp)) ||
+ (routine = iioctl_server_routine (inp)) ||
+ (routine = NULL, trivfs_demuxer (inp, outp)) ||
+ (routine = startup_notify_server_routine (inp)))
+ {
+ if (routine)
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
else
- return (socket_server (inp, outp)
- || pfinet_server (inp, outp)
- || iioctl_server (inp, outp)
- || trivfs_demuxer (inp, outp)
- || startup_notify_server (inp, outp));
+ {
+ mig_routine_t routine;
+ if ((routine = socket_server_routine (inp)) ||
+ (routine = pfinet_server_routine (inp)) ||
+ (routine = iioctl_server_routine (inp)) ||
+ (routine = NULL, trivfs_demuxer (inp, outp)) ||
+ (routine = startup_notify_server_routine (inp)))
+ {
+ if (routine)
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
}
/* The system is going down; destroy all the extant port rights. That
--
1.7.10.4
- Improving the demuxer functions, Justus Winter, 2013/11/29
- [PATCH] libdiskfs: improve the diskfs_demuxer function, Justus Winter, 2013/11/29
- [PATCH 1/7] libdiskfs: improve the diskfs_demuxer function, Justus Winter, 2013/11/30
- [PATCH 3/7] libtrivfs: improve the trivfs_demuxer function, Justus Winter, 2013/11/30
- [PATCH 2/7] libnetfs: improve the netfs_demuxer function, Justus Winter, 2013/11/30
- [PATCH 5/7] proc: improve the message_demuxer function, Justus Winter, 2013/11/30
- [PATCH 4/7] exec: improve the exec_demuxer function, Justus Winter, 2013/11/30
- [PATCH 6/7] pfinet: improve the pfinet_demuxer function,
Justus Winter <=
- [PATCH 7/7] pflocal: improve the demuxer functions, Justus Winter, 2013/11/30