VFS: close handles via handle method

The using pattern 'handle->close' is less error prone than attempting
'handle->ds().close(handle)' or 'fs.close(handle)'.

Ref #2782
This commit is contained in:
Emery Hemingway
2018-04-23 09:25:51 +02:00
committed by Christian Helmuth
parent 09ad962418
commit 0b980073c1
5 changed files with 36 additions and 20 deletions

View File

@ -79,7 +79,7 @@ class Vfs::Dir_file_system : public File_system
{
/* close all sub-handles */
auto f = [&] (Subdir_handle_element &e) {
e.vfs_handle.ds().close(&e.vfs_handle);
e.vfs_handle.close();
destroy(alloc(), &e);
};
subdir_handle_registry.for_each(f);
@ -118,7 +118,7 @@ class Vfs::Dir_file_system : public File_system
{
/* close all sub-handles */
auto f = [&] (Watch_handle_element &e) {
e.watch_handle.fs().close(&e.watch_handle);
e.watch_handle.close();
destroy(alloc(), &e);
};
handle_registry.for_each(f);
@ -700,8 +700,9 @@ class Vfs::Dir_file_system : public File_system
Vfs_handle *tmp_handle;
Opendir_result opendir_result =
fs.opendir(path, true, &tmp_handle, alloc);
if (opendir_result == OPENDIR_OK)
fs.close(tmp_handle);
if (opendir_result == OPENDIR_OK) {
tmp_handle->close();
}
return opendir_result; /* return from lambda */
};