1.1 --- a/libfsserver/lib/generic/resource_server.cc Mon Mar 20 22:38:24 2023 +0100
1.2 +++ b/libfsserver/lib/generic/resource_server.cc Tue Mar 21 19:23:34 2023 +0100
1.3 @@ -61,9 +61,19 @@
1.4 return resource_start_config(_config, _resource);
1.5 }
1.6
1.7 -/* Start a new thread with deletion notifications and finalisation. */
1.8 +/* Start serving a resource in an existing thread. */
1.9 +
1.10 +long ResourceServer::start_in_thread(l4_cap_idx_t thread, bool finalisation)
1.11 +{
1.12 + resource_init_config(_config, _resource);
1.13 + resource_set_config_threaded(_config, thread, 1, finalisation);
1.14
1.15 -long ResourceServer::start_thread()
1.16 + return resource_start_config(_config, _resource);
1.17 +}
1.18 +
1.19 +/* Start serving a resource in a new thread. */
1.20 +
1.21 +long ResourceServer::start_thread(bool finalisation)
1.22 {
1.23 pthread_t thread;
1.24 pthread_attr_t attr;
1.25 @@ -78,7 +88,7 @@
1.26 if (err)
1.27 return err;
1.28
1.29 - resource_set_config_threaded(_config, pthread_l4_cap(thread), 1);
1.30 + resource_set_config_threaded(_config, pthread_l4_cap(thread), 1, finalisation);
1.31
1.32 return resource_start_config(_config, _resource);
1.33 }
1.34 @@ -86,9 +96,9 @@
1.35 /* A convenience method starting a thread and returning the server capability
1.36 employed via the given parameter. */
1.37
1.38 -long ResourceServer::start_thread(l4_cap_idx_t *server)
1.39 +long ResourceServer::start_thread(l4_cap_idx_t *server, bool finalisation)
1.40 {
1.41 - long err = start_thread();
1.42 + long err = start_thread(finalisation);
1.43
1.44 if (!err)
1.45 *server = _config->server;
1.46 @@ -113,12 +123,13 @@
1.47 /* Set a configuration to be threaded. */
1.48
1.49 void resource_set_config_threaded(ipc_server_config_type *config,
1.50 - l4_cap_idx_t thread, int new_thread)
1.51 + l4_cap_idx_t thread, int new_thread,
1.52 + int finalisation)
1.53 {
1.54 config->finaliser = resource_thread_finaliser;
1.55 config->config_thread = new_thread;
1.56 config->thread = thread;
1.57 - config->notifications = 1;
1.58 + config->notifications = finalisation;
1.59 }
1.60
1.61 /* Activate a resource and start a server for it. */