From 8a4f4fcea9c5309c080d4717030da4dfe3b1f601 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Thu, 7 Apr 2022 16:06:11 +0200 Subject: [PATCH] vfs_rump: reflect resource shortage as return values The function Vfs::Directory_service::watch() is not expected to throw Out_of_ram/Out_of_caps but use dedicated Watch_result errors. --- repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc b/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc index bc17acde4f..498c5ee492 100644 --- a/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc +++ b/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc @@ -758,11 +758,15 @@ class Vfs::Rump_file_system : public File_system if (fd < 0) return WATCH_ERR_UNACCESSIBLE; - auto *watch_handle = new (alloc) - Rump_watch_handle(*this, alloc, fd); - _watchers.insert(watch_handle); - *handle = watch_handle; - return WATCH_OK; + try { + auto *watch_handle = new (alloc) + Rump_watch_handle(*this, alloc, fd); + _watchers.insert(watch_handle); + *handle = watch_handle; + return WATCH_OK; + } + catch (Genode::Out_of_ram) { return WATCH_ERR_OUT_OF_RAM; } + catch (Genode::Out_of_caps) { return WATCH_ERR_OUT_OF_CAPS; } } void close(Vfs_watch_handle *vfs_handle) override