diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-11-30 17:48:17 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-12-02 17:31:14 +0100 |
commit | b8b92e2455c2a9652e60a17dd38fc8dc031b77c3 (patch) | |
tree | ebc36971d3985d4afb135f70a38655654e130fa7 /pflocal/sserver.c | |
parent | 9cec7a2482a68ca1ae41d65fc8b94584d5020c3f (diff) | |
download | hurd-b8b92e2455c2a9652e60a17dd38fc8dc031b77c3.tar.gz hurd-b8b92e2455c2a9652e60a17dd38fc8dc031b77c3.tar.bz2 hurd-b8b92e2455c2a9652e60a17dd38fc8dc031b77c3.zip |
pflocal: improve the demuxer functions
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.
* pflocal/pflocal.c (pf_demuxer): Improve the demuxer function.
* pflocal/sserver.c (sock_demuxer): Likewise.
Diffstat (limited to 'pflocal/sserver.c')
-rw-r--r-- | pflocal/sserver.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/pflocal/sserver.c b/pflocal/sserver.c index 9de0aa54..4ce26b13 100644 --- a/pflocal/sserver.c +++ b/pflocal/sserver.c @@ -1,6 +1,6 @@ /* Server for socket ops - Copyright (C) 1995, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 2013 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -36,13 +36,22 @@ static pthread_spinlock_t sock_server_active_lock = PTHREAD_SPINLOCK_INITIALIZER static int sock_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - extern int socket_server (mach_msg_header_t *inp, mach_msg_header_t *outp); - extern int io_server (mach_msg_header_t *inp, mach_msg_header_t *outp); - return - socket_server (inp, outp) - || io_server (inp, outp) - || ports_interrupt_server (inp, outp) - || ports_notify_server (inp, outp); + 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 routine; + if ((routine = io_server_routine (inp)) || + (routine = socket_server_routine (inp)) || + (routine = ports_interrupt_server_routine (inp)) || + (routine = ports_notify_server_routine (inp))) + { + (*routine) (inp, outp); + return TRUE; + } + else + return FALSE; } /* Handle socket requests while there are sockets around. */ |