[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] libtrivfs: improve the trivfs_demuxer function
From: |
Justus Winter |
Subject: |
[PATCH 3/7] libtrivfs: improve the trivfs_demuxer function |
Date: |
Sat, 30 Nov 2013 20:10:59 +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.
* libtriv/demuxer.c (trivfs_demuxer): Improve the demuxer function.
---
libtrivfs/demuxer.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/libtrivfs/demuxer.c b/libtrivfs/demuxer.c
index 49ee45a..411699f 100644
--- a/libtrivfs/demuxer.c
+++ b/libtrivfs/demuxer.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1993, 1994 Free Software Foundation
+ Copyright (C) 1993, 1994, 2013 Free Software Foundation
This file is part of the GNU Hurd.
@@ -25,13 +25,23 @@ int
trivfs_demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
{
- int trivfs_fs_server (mach_msg_header_t *, mach_msg_header_t *);
- int trivfs_io_server (mach_msg_header_t *, mach_msg_header_t *);
- int trivfs_fsys_server (mach_msg_header_t *, mach_msg_header_t *);
-
- return (trivfs_io_server (inp, outp)
- || trivfs_fs_server (inp, outp)
- || ports_notify_server (inp, outp)
- || trivfs_fsys_server (inp, outp)
- || ports_interrupt_server (inp, outp));
+ mig_routine_t trivfs_io_server_routine (mach_msg_header_t *);
+ mig_routine_t trivfs_fs_server_routine (mach_msg_header_t *);
+ mig_routine_t ports_notify_server_routine (mach_msg_header_t *);
+ mig_routine_t trivfs_fsys_server_routine (mach_msg_header_t *);
+ mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *);
+ mig_routine_t trivfs_ifsock_server_routine (mach_msg_header_t *);
+
+ mig_routine_t routine;
+ if ((routine = trivfs_io_server_routine (inp)) ||
+ (routine = trivfs_fs_server_routine (inp)) ||
+ (routine = ports_notify_server_routine (inp)) ||
+ (routine = trivfs_fsys_server_routine (inp)) ||
+ (routine = ports_interrupt_server_routine (inp)))
+ {
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
--
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 <=
- [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, 2013/11/30
- [PATCH 7/7] pflocal: improve the demuxer functions, Justus Winter, 2013/11/30