mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-16 07:27:35 +00:00
vfs/cbe_trust_anchor: close handles correctly
The plugin used to close file handles via the 'vfs_env.root_dir.close'. However, this lead to resource leaks and apparently isn't the right way to do it. Other VFS plugins do it by calling 'close' directly on the handle and doing it in the trust anchor plugin also, fixes the leaks. Ref #4032
This commit is contained in:
parent
df7de17435
commit
95639a7492
@ -428,6 +428,12 @@ class Trust_anchor
|
||||
|
||||
Io_response_handler _io_response_handler { _io_handler };
|
||||
|
||||
void _close_handle(Vfs::Vfs_handle **handle)
|
||||
{
|
||||
(*handle)->close();
|
||||
(*handle) = nullptr;
|
||||
}
|
||||
|
||||
/* key */
|
||||
|
||||
Vfs::Vfs_handle *_key_handle { nullptr };
|
||||
@ -489,8 +495,7 @@ class Trust_anchor
|
||||
Util::Io_job::Partial_result::ALLOW);
|
||||
if (_key_io_job->execute() && _key_io_job->completed()) {
|
||||
_state = State::INITIALIZED;
|
||||
_vfs_env.root_dir().close(_key_handle);
|
||||
_key_handle = nullptr;
|
||||
_close_handle(&_key_handle);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@ -508,8 +513,7 @@ class Trust_anchor
|
||||
bool const completed = _key_io_job->completed();
|
||||
if (completed) {
|
||||
_state = State::INITIALIZED;
|
||||
_vfs_env.root_dir().close(_key_handle);
|
||||
_key_handle = nullptr;
|
||||
_close_handle(&_key_handle);
|
||||
_key_io_job.destruct();
|
||||
}
|
||||
|
||||
@ -539,8 +543,7 @@ class Trust_anchor
|
||||
_key_io_job_buffer, 0);
|
||||
if (_key_io_job->execute() && _key_io_job->completed()) {
|
||||
_state = State::INITIALIZED;
|
||||
_vfs_env.root_dir().close(_key_handle);
|
||||
_key_handle = nullptr;
|
||||
_close_handle(&_key_handle);
|
||||
_key_io_job.destruct();
|
||||
return true;
|
||||
}
|
||||
@ -559,8 +562,7 @@ class Trust_anchor
|
||||
bool const completed = _key_io_job->completed();
|
||||
if (completed) {
|
||||
_state = State::INITIALIZED;
|
||||
_vfs_env.root_dir().close(_key_handle);
|
||||
_key_handle = nullptr;
|
||||
_close_handle(&_key_handle);
|
||||
_key_io_job.destruct();
|
||||
}
|
||||
|
||||
@ -608,8 +610,7 @@ class Trust_anchor
|
||||
_hash_io_job_buffer, 0,
|
||||
Util::Io_job::Partial_result::ALLOW);
|
||||
if (_hash_io_job->execute() && _hash_io_job->completed()) {
|
||||
_vfs_env.root_dir().close(_hash_handle);
|
||||
_hash_handle = nullptr;
|
||||
_close_handle(&_hash_handle);
|
||||
_hash_io_job.destruct();
|
||||
return true;
|
||||
}
|
||||
@ -624,8 +625,7 @@ class Trust_anchor
|
||||
bool const progress = _hash_io_job->execute();
|
||||
bool const completed = _hash_io_job->completed();
|
||||
if (completed) {
|
||||
_vfs_env.root_dir().close(_hash_handle);
|
||||
_hash_handle = nullptr;
|
||||
_close_handle(&_hash_handle);
|
||||
_hash_io_job.destruct();
|
||||
}
|
||||
|
||||
@ -638,14 +638,6 @@ class Trust_anchor
|
||||
_hash_io_job_buffer, 0);
|
||||
}
|
||||
|
||||
void _close_hash_handle()
|
||||
{
|
||||
_vfs_env.root_dir().close(_hash_handle);
|
||||
Genode::destroy(_hash_handle->alloc(), _hash_handle);
|
||||
_hash_handle = nullptr;
|
||||
_hash_io_job.destruct();
|
||||
}
|
||||
|
||||
bool _open_hash_file_and_write(Path const &path)
|
||||
{
|
||||
using Result = Vfs::Directory_service::Open_result;
|
||||
@ -705,7 +697,8 @@ class Trust_anchor
|
||||
bool const progress = _hash_io_job->execute();
|
||||
bool const completed = _hash_io_job->completed();
|
||||
if (completed) {
|
||||
_close_hash_handle();
|
||||
_close_handle(&_hash_handle);
|
||||
_hash_io_job.destruct();
|
||||
}
|
||||
return progress && completed;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user