From 1ad178fd00b675d686c2560829e9a10c5cb44f6f Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Wed, 7 Jan 2015 16:05:48 +0100 Subject: proc: call `startup_essential_task' earlier Previously, the proc server did not call `startup_essential_task' until it got the message port of the startup server using `proc_setmsgport'. Now that we have `/servers/startup', we can do this in main, before we start our message service loop. A complication arises because the traditional startup server is single-threaded. Handle this by tweaking startup not to bind itself to `/servers/startup' before it is ready. * proc/main.c (main): Try to lookup `/servers/startup' and send the message here, or... * proc/msg.c (S_proc_setmsgport): ... fall back to the old way here. * proc/proc.h (startup_fallback): New variable. * startup/startup.c (main): Move code installing ourself on `/servers/startup' (install_as_translator): ... here. (launch_core_servers): And use it here, just before we reply to `/hurd/auth'. --- startup/startup.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'startup') diff --git a/startup/startup.c b/startup/startup.c index c9fe215a..e01d2a83 100644 --- a/startup/startup.c +++ b/startup/startup.c @@ -514,6 +514,32 @@ demuxer (mach_msg_header_t *inp, startup_server (inp, outp)); } +error_t +install_as_translator (void) +{ + error_t err; + file_t node; + + node = file_name_lookup (_SERVERS_STARTUP, O_NOTRANS, 0); + if (! MACH_PORT_VALID (node)) + { + if (errno == ENOENT) + { + /* Degrade gracefully if the node does not exist. */ + error (0, errno, "%s", _SERVERS_STARTUP); + return 0; + } + return errno; + } + + err = file_set_translator (node, + 0, FS_TRANS_SET, 0, + NULL, 0, + startup, MACH_MSG_TYPE_COPY_SEND); + mach_port_deallocate (mach_task_self (), node); + return err; +} + static int parse_opt (int key, char *arg, struct argp_state *state) { @@ -587,18 +613,6 @@ main (int argc, char **argv, char **envp) /* Crash if the boot filesystem task dies. */ request_dead_name (fstask); - file_t node = file_name_lookup (_SERVERS_STARTUP, O_NOTRANS, 0); - if (node == MACH_PORT_NULL) - error (0, errno, "%s", _SERVERS_STARTUP); - else - { - file_set_translator (node, - 0, FS_TRANS_SET, 0, - NULL, 0, - startup, MACH_MSG_TYPE_COPY_SEND); - mach_port_deallocate (mach_task_self (), node); - } - /* Set up the set of ports we will pass to the programs we exec. */ for (i = 0; i < INIT_PORT_MAX; i++) switch (i) @@ -672,6 +686,12 @@ launch_core_servers (void) proc_task2proc (procserver, authtask, &authproc); proc_mark_important (authproc); proc_mark_exec (authproc); + + err = install_as_translator (); + if (err) + /* Good luck. Who knows, maybe it's an old installation. */ + error (0, err, "Failed to bind to " _SERVERS_STARTUP); + startup_authinit_reply (authreply, authreplytype, 0, authproc, MACH_MSG_TYPE_COPY_SEND); mach_port_deallocate (mach_task_self (), authproc); -- cgit v1.2.3