From 71aacd7ed8d1b89c5338f4f98201123c175a8024 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 30 Aug 2013 08:46:21 +0200 Subject: [PATCH] noux: first remove from list, then dissolve Avoids deadlock - which is out of the list can't be found twice to be deleted. Issue #485 --- ports/src/noux/dataspace_registry.h | 10 ++++------ ports/src/noux/local_rm_service.h | 13 ++++++++----- ports/src/noux/ram_session_component.h | 3 ++- ports/src/noux/rom_session_component.h | 10 ++++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ports/src/noux/dataspace_registry.h b/ports/src/noux/dataspace_registry.h index 150e40d7ab..c98e26b7c0 100644 --- a/ports/src/noux/dataspace_registry.h +++ b/ports/src/noux/dataspace_registry.h @@ -124,11 +124,7 @@ namespace Noux { * created via 'Rm_dataspace_info::fork', are not handled by * those destructors. So we have to clean them up here. */ - for (;;) { - Dataspace_info *info = _pool.first(); - if (!info) - return; - + while(Dataspace_info *info = _pool.first()) { _pool.remove_locked(info); destroy(env()->heap(), info); } @@ -172,8 +168,10 @@ namespace Noux { return; } - info->dissolve_users(); _ds_registry.remove(info); + + info->dissolve_users(); + } Dataspace_capability fork(Ram_session_capability, diff --git a/ports/src/noux/local_rm_service.h b/ports/src/noux/local_rm_service.h index 7217c1b579..a90ad6727c 100644 --- a/ports/src/noux/local_rm_service.h +++ b/ports/src/noux/local_rm_service.h @@ -132,13 +132,16 @@ namespace Noux { /* release dataspace info */ Dataspace_info *info = _ds_registry.lookup_info(ds_cap); - if (info) { - info->dissolve_users(); - _ds_registry.remove(info); - destroy(env()->heap(), info); - } else { + if (!info) { PWRN("Could not lookup dataspace info for local RM session"); + return; } + + _ds_registry.remove(info); + + info->dissolve_users(); + + destroy(env()->heap(), info); } }; } diff --git a/ports/src/noux/ram_session_component.h b/ports/src/noux/ram_session_component.h index 38f7586072..2ea6e30a26 100644 --- a/ports/src/noux/ram_session_component.h +++ b/ports/src/noux/ram_session_component.h @@ -161,9 +161,10 @@ namespace Noux { return; } + _registry.remove(ds_info); + ds_info->dissolve_users(); - _registry.remove(ds_info); _list.remove(ds_info); _used_quota -= ds_info->size(); diff --git a/ports/src/noux/rom_session_component.h b/ports/src/noux/rom_session_component.h index 3d0756c605..9087877449 100644 --- a/ports/src/noux/rom_session_component.h +++ b/ports/src/noux/rom_session_component.h @@ -66,18 +66,20 @@ namespace Noux { ~Rom_session_component() { /* - * Lookup and lock ds info instead of directly acccessing + * Lookup and lock ds info instead of directly accessing * the '_ds_info' member. */ Object_pool::Guard info(_ds_registry.lookup_info(_ds_info.ds_cap())); - if (info) - info->dissolve_users(); - else + if (!info) { PERR("~Rom_session_component: unexpected !info"); + return; + } _ds_registry.remove(&_ds_info); + + info->dissolve_users(); }