vfs/ram: avoid 2x mutex releases in guard

Issue #3612
This commit is contained in:
Alexander Boettcher 2020-04-01 15:45:12 +02:00 committed by Christian Helmuth
parent 2b41323fe6
commit 13cd25e7b0

View File

@ -244,10 +244,11 @@ class Vfs_ram::Node : private Genode::Avl_node<Node>, private Genode::Mutex
struct Guard struct Guard
{ {
Node &node; Node &node;
bool release { true };
Guard(Node *guard_node) : node(*guard_node) { node.acquire(); } Guard(Node *guard_node) : node(*guard_node) { node.acquire(); }
~Guard() { node.release(); } ~Guard() { if (release) node.release(); }
}; };
}; };
@ -837,8 +838,10 @@ class Vfs::Ram_file_system : public Vfs::File_system
if (!to_dir) return RENAME_ERR_NO_ENTRY; if (!to_dir) return RENAME_ERR_NO_ENTRY;
/* unlock the node so a second guard can be constructed */ /* unlock the node so a second guard can be constructed */
if (from_dir == to_dir) if (from_dir == to_dir) {
from_dir->Node::release(); from_dir->Node::release();
from_guard.release = false;
}
Node::Guard to_guard(to_dir); Node::Guard to_guard(to_dir);