VFS: Replace global response handlers with local handlers

Replace the I/O response handler that is passed to the VFS at
construction with an object that is dynamically attached to handles.
This object shall also accept read-ready notifications, and plugins are
encouraged to keep handles awaiting ready-ready notifications separate
from handles that await I/O progress.

Replace the use of handle lists in plugins with handle queues, this
makes the code easier to understand and the ordering of notifications to
the application more explicit.

These changes replace the use of the Post_signal_hook from all VFS
plugins, applications must assume that read-ready and I/O notifications
occur during I/O signal dispatch and use an Io_progress_handler at its
entrypoints to defer response until after signal dispatching.

Fix #3257
This commit is contained in:
Emery Hemingway
2019-03-25 15:41:43 +01:00
committed by Christian Helmuth
parent e2ff776b35
commit a635873568
27 changed files with 1397 additions and 1341 deletions

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
* Copyright (C) 2011-2019 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
@ -125,12 +125,12 @@ class Vfs::Dir_file_system : public File_system
}
/**
* Propagate the handle context to each sub-handle
* Propagate the response handler to each sub-handle
*/
void context(Context *ctx) override
void handler(Watch_response_handler *h) override
{
handle_registry.for_each( [&] (Watch_handle_element &elem) {
elem.watch_handle.context(ctx); } );
elem.watch_handle.handler(h); } );
}
};
@ -313,8 +313,9 @@ class Vfs::Dir_file_system : public File_system
index = index - base;
vfs_handle.seek(index * sizeof(Dirent));
/* forward the handle context */
vfs_handle.context(dir_vfs_handle->context());
/* forward the response handler */
dir_vfs_handle->apply_handler([&] (Vfs::Io_response_handler &h) {
vfs_handle.handler(&h); });
result = vfs_handle.fs().queue_read(&vfs_handle, sizeof(Dirent));
}
@ -950,8 +951,9 @@ class Vfs::Dir_file_system : public File_system
static_cast<Dir_vfs_handle*>(vfs_handle);
auto f = [&result, dir_vfs_handle] (Dir_vfs_handle::Subdir_handle_element &e) {
/* forward the handle context */
e.vfs_handle.context(dir_vfs_handle->context());
/* forward the response handler */
dir_vfs_handle->apply_handler([&] (Io_response_handler &h) {
e.vfs_handle.handler(&h); });
e.synced = false;
if (!e.vfs_handle.fs().queue_sync(&e.vfs_handle)) {