1.1 --- a/libresource/lib/src/resource_server.cc Wed Mar 22 16:15:04 2023 +0100
1.2 +++ b/libresource/lib/src/resource_server.cc Wed Mar 22 17:31:05 2023 +0100
1.3 @@ -38,8 +38,8 @@
1.4 return ipc_server_bind(name, (l4_umword_t) _config, &_config->server);
1.5 }
1.6
1.7 -/* Start in the same thread indicating whether deletion notifications and
1.8 - finalisation are to be used. */
1.9 +/* Start in the same thread indicating whether the server can be finalised. If
1.10 + so, deletion notifications will be used. */
1.11
1.12 long ResourceServer::start(bool finalisation)
1.13 {
1.14 @@ -56,24 +56,26 @@
1.15 {
1.16 _config->finaliser = resource_same_thread_finaliser;
1.17 _config->notifications = 1;
1.18 + _config->auto_deletion = 1;
1.19 }
1.20
1.21 return resource_start_config(_config, _resource);
1.22 }
1.23
1.24 -/* Start serving a resource in an existing thread. */
1.25 +/* Start serving a resource in an existing thread. The resource will not be
1.26 + finalised. */
1.27
1.28 -long ResourceServer::start_in_thread(l4_cap_idx_t thread, bool finalisation)
1.29 +long ResourceServer::start_in_thread(l4_cap_idx_t thread)
1.30 {
1.31 resource_init_config(_config, _resource);
1.32 - resource_set_config_threaded(_config, thread, 1, finalisation);
1.33 + resource_set_config_threaded(_config, thread, 1, 0, 0);
1.34
1.35 return resource_start_config(_config, _resource);
1.36 }
1.37
1.38 /* Start serving a resource in a new thread. */
1.39
1.40 -long ResourceServer::start_thread(bool finalisation)
1.41 +long ResourceServer::start_thread(bool finalisation, bool auto_deletion)
1.42 {
1.43 pthread_t thread;
1.44 pthread_attr_t attr;
1.45 @@ -88,7 +90,8 @@
1.46 if (err)
1.47 return err;
1.48
1.49 - resource_set_config_threaded(_config, pthread_l4_cap(thread), 1, finalisation);
1.50 + resource_set_config_threaded(_config, pthread_l4_cap(thread), 1, finalisation,
1.51 + auto_deletion);
1.52
1.53 return resource_start_config(_config, _resource);
1.54 }
1.55 @@ -96,9 +99,10 @@
1.56 /* A convenience method starting a thread and returning the server capability
1.57 employed via the given parameter. */
1.58
1.59 -long ResourceServer::start_thread(l4_cap_idx_t *server, bool finalisation)
1.60 +long ResourceServer::start_thread(l4_cap_idx_t *server, bool finalisation,
1.61 + bool auto_deletion)
1.62 {
1.63 - long err = start_thread(finalisation);
1.64 + long err = start_thread(finalisation, auto_deletion);
1.65
1.66 if (!err)
1.67 *server = _config->server;
1.68 @@ -123,13 +127,16 @@
1.69 /* Set a configuration to be threaded. */
1.70
1.71 void resource_set_config_threaded(ipc_server_config_type *config,
1.72 - l4_cap_idx_t thread, int new_thread,
1.73 - int finalisation)
1.74 + l4_cap_idx_t thread, int separate_thread,
1.75 + int finalisation, int auto_deletion)
1.76 {
1.77 - config->finaliser = resource_thread_finaliser;
1.78 - config->config_thread = new_thread;
1.79 + if (finalisation)
1.80 + config->finaliser = resource_thread_finaliser;
1.81 +
1.82 + config->config_thread = separate_thread;
1.83 config->thread = thread;
1.84 config->notifications = finalisation;
1.85 + config->auto_deletion = auto_deletion;
1.86 }
1.87
1.88 /* Activate a resource and start a server for it. */