diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-01-07 16:05:48 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-01-17 18:24:59 +0100 |
commit | 1ad178fd00b675d686c2560829e9a10c5cb44f6f (patch) | |
tree | 0c2924328228307558ce52ce829274de27fde755 /proc/main.c | |
parent | 40b354e4cc67f1fedf9d4c2ce8d050a9ac68a643 (diff) |
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'.
Diffstat (limited to 'proc/main.c')
-rw-r--r-- | proc/main.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/proc/main.c b/proc/main.c index b4288fbc..6df41415 100644 --- a/proc/main.c +++ b/proc/main.c @@ -22,6 +22,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <mach.h> #include <hurd/hurd_types.h> #include <hurd.h> +#include <hurd/paths.h> #include <hurd/startup.h> #include <device/device.h> #include <assert.h> @@ -62,6 +63,7 @@ message_demuxer (mach_msg_header_t *inp, } pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; +int startup_fallback; error_t increase_priority (void) @@ -99,6 +101,7 @@ main (int argc, char **argv, char **envp) error_t err; void *genport; process_t startup_port; + mach_port_t startup; struct argp argp = { 0, 0, 0, "Hurd process server" }; argp_parse (&argp, argc, argv, 0, 0, 0); @@ -173,6 +176,26 @@ main (int argc, char **argv, char **envp) mach_port_deallocate (mach_task_self (), cons); } + startup = file_name_lookup (_SERVERS_STARTUP, 0, 0); + if (MACH_PORT_VALID (startup)) + { + err = startup_essential_task (startup, mach_task_self (), + MACH_PORT_NULL, "proc", _hurd_host_priv); + if (err) + /* Due to the single-threaded nature of /hurd/startup, it can + only handle requests once the core server bootstrap has + completed. Therefore, it does not bind itself to + /servers/startup until it is ready. */ + /* Fall back to abusing the message port lookup. */ + startup_fallback = 1; + + err = mach_port_deallocate (mach_task_self (), startup); + assert_perror (err); + } + else + /* Fall back to abusing the message port lookup. */ + startup_fallback = 1; + while (1) ports_manage_port_operations_multithread (proc_bucket, message_demuxer, |