diff options
author | Damien Zammit <damien@zamaudio.com> | 2021-03-02 22:41:35 +1100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-03-02 22:12:56 +0100 |
commit | 47501a9a39d7835d4c80aa8ed7531c6c101101fb (patch) | |
tree | 96b2bdc4826d4d42b08840081f85b58c48249f00 /libmachdev | |
parent | c1ae388a59b58f7c86412e7bfaee1d07f58e6ecc (diff) | |
download | hurd-47501a9a39d7835d4c80aa8ed7531c6c101101fb.tar.gz hurd-47501a9a39d7835d4c80aa8ed7531c6c101101fb.tar.bz2 hurd-47501a9a39d7835d4c80aa8ed7531c6c101101fb.zip |
libmachdev: Spawn a thread for server loop so main pathway can continue
Message-Id: <20210302114137.592230-3-damien@zamaudio.com>
Diffstat (limited to 'libmachdev')
-rw-r--r-- | libmachdev/trivfs_server.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c index 3ab15049..d1d3a71d 100644 --- a/libmachdev/trivfs_server.c +++ b/libmachdev/trivfs_server.c @@ -398,7 +398,8 @@ machdev_trivfs_init(mach_port_t bootstrap_resume_task, const char *name, const c if (path) devnode = strdup(path); resume_bootstrap_server(bootstrap_resume_task, name); - *bootstrap = MACH_PORT_NULL; + *bootstrap = ports_get_send_right (&control->pi); + /* We need to install as a translator later */ bootstrapped = TRUE; } @@ -479,13 +480,29 @@ trivfs_modify_stat (struct trivfs_protid *cred, io_statbuf_t *stat) { } +static void * +machdev_trivfs_loop(void *arg) +{ + struct trivfs_control *fsys = (struct trivfs_control *)arg; + + /* Launch. */ + do + { + ports_manage_port_operations_one_thread (port_bucket, demuxer, 0); + } while (trivfs_goaway (fsys, 0)); + + /* Never reached */ + return 0; +} + void machdev_trivfs_server(mach_port_t bootstrap) { struct trivfs_control *fsys = NULL; int err; + pthread_t t; - if (bootstrap != MACH_PORT_NULL) + if (bootstrapped == FALSE) { /* This path is executed when a parent exists */ err = trivfs_startup (bootstrap, 0, @@ -500,9 +517,8 @@ machdev_trivfs_server(mach_port_t bootstrap) fsys = control; } - /* Launch. */ - do - { - ports_manage_port_operations_one_thread (port_bucket, demuxer, 0); - } while (trivfs_goaway (fsys, 0)); + err = pthread_create (&t, NULL, machdev_trivfs_loop, (void *)fsys); + if (err) + error (1, err, "Creating machdev server thread"); + pthread_detach (t); } |