# HG changeset patch # User Paul Boddie # Date 1666371785 -7200 # Node ID 7cedafa1cdaa310c311a5fa10d3d42d2ef8b7d9e # Parent 328868b6085135280d94c07177dec0d297052d57 Employ the existing pending removal flag to control removal. Removed the superfluous remove method since it will not do any meaningful additional work if only pending removal is supported. diff -r 328868b60851 -r 7cedafa1cdaa docs/wiki/Server_Library --- a/docs/wiki/Server_Library Thu Oct 20 23:08:28 2022 +0200 +++ b/docs/wiki/Server_Library Fri Oct 21 19:03:05 2022 +0200 @@ -68,7 +68,6 @@ ProviderRegistry *registry(); long make_resource(offset_t *size, object_flags_t *object_flags, Resource **resource); bool removal_pending(); -void remove(); void remove_pending(bool remove); }}} @@ -79,12 +78,11 @@ provider exercises its use of that provider. The `make_resource` operation performs the creation and returns size, flags and resource instance details. -The removal of providers can be directed using the `remove_pending` and -`remove` operations. Where `remove_pending` has been called with a true value -as its parameter, the `removal_pending` operation will also return a true -value, and upon the provider being discarded, the `remove` operation will be -invoked. The `remove` operation performs the appropriate underlying operation -to remove the object being provided. +The removal of providers can be directed using the `remove_pending` operation. +Where `remove_pending` has been called with a true value as its parameter, the +`removal_pending` operation will also return a true value, and upon the +provider being discarded, a removal operation will be invoked on the +underlying object being provided. Typically, removal of providers is managed by the provider registry when resources are closed and detached from providers. @@ -101,7 +99,7 @@ ResourceServer -> Resource [label="close"]; Resource -> ProviderRegistry [label="detach"]; - ProviderRegistry -> Provider [label="remove"]; + ProviderRegistry -> Provider [label="delete"]; } }}} diff -r 328868b60851 -r 7cedafa1cdaa libfsserver/include/fsserver/file_provider.h --- a/libfsserver/include/fsserver/file_provider.h Thu Oct 20 23:08:28 2022 +0200 +++ b/libfsserver/include/fsserver/file_provider.h Fri Oct 21 19:03:05 2022 +0200 @@ -32,7 +32,6 @@ { protected: PageMapper *_mapper; - bool _to_remove = false; public: explicit FileProvider(fileid_t fileid, ProviderRegistry *registry, @@ -45,8 +44,6 @@ virtual long make_resource(flags_t flags, offset_t *size, object_flags_t *object_flags, Resource **resource); - - virtual void remove(); }; // vim: tabstop=4 expandtab shiftwidth=4 diff -r 328868b60851 -r 7cedafa1cdaa libfsserver/include/fsserver/provider.h --- a/libfsserver/include/fsserver/provider.h Thu Oct 20 23:08:28 2022 +0200 +++ b/libfsserver/include/fsserver/provider.h Fri Oct 21 19:03:05 2022 +0200 @@ -52,8 +52,6 @@ virtual bool removal_pending(); - virtual void remove(); - virtual void remove_pending(bool remove); }; diff -r 328868b60851 -r 7cedafa1cdaa libfsserver/lib/files/file_provider.cc --- a/libfsserver/lib/files/file_provider.cc Thu Oct 20 23:08:28 2022 +0200 +++ b/libfsserver/lib/files/file_provider.cc Fri Oct 21 19:03:05 2022 +0200 @@ -44,7 +44,7 @@ accessor->close(); - if (_to_remove) + if (_remove) accessor->remove(); delete accessor; @@ -79,13 +79,4 @@ return L4_EOK; } -/* Lifecycle methods. */ - -/* Remove the file using the accessor. */ - -void FileProvider::remove() -{ - _to_remove = true; -} - // vim: tabstop=4 expandtab shiftwidth=4 diff -r 328868b60851 -r 7cedafa1cdaa libfsserver/lib/generic/provider.cc --- a/libfsserver/lib/generic/provider.cc Thu Oct 20 23:08:28 2022 +0200 +++ b/libfsserver/lib/generic/provider.cc Fri Oct 21 19:03:05 2022 +0200 @@ -42,10 +42,6 @@ return _remove; } -void Provider::remove() -{ -} - void Provider::remove_pending(bool remove) { _remove = remove; diff -r 328868b60851 -r 7cedafa1cdaa libfsserver/lib/generic/provider_registry.cc --- a/libfsserver/lib/generic/provider_registry.cc Thu Oct 20 23:08:28 2022 +0200 +++ b/libfsserver/lib/generic/provider_registry.cc Fri Oct 21 19:03:05 2022 +0200 @@ -73,17 +73,11 @@ { std::lock_guard guard(_lock); - if (!provider->detach()) - { - /* Remove any underlying object if pending. */ + /* Remove from the registry, also removing any underlying object if removal + is pending. */ - if (provider->removal_pending()) - provider->remove(); - - /* Remove from the registry. */ - + if (!provider->detach()) remove(fileid, provider); - } } // vim: tabstop=4 expandtab shiftwidth=4