nitpicker: prevent deadlock in destroy_view

Fixes #1649
This commit is contained in:
Norman Feske 2015-08-18 15:31:55 +02:00 committed by Christian Helmuth
parent 9402261dda
commit 795375796f

View File

@ -815,12 +815,26 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
void destroy_view(View_handle handle) override
{
try {
Locked_ptr<View> view(_view_handle_registry.lookup(handle));
if (view.is_valid())
_destroy_view(*view);
/*
* Search view object given the handle
*
* We cannot look up the view directly from the
* '_view_handle_registry' because we would obtain a weak
* pointer to the view object. If we called the object's
* destructor from the corresponding locked pointer, the
* call of 'lock_for_destruction' in the view's destructor
* would attempt to take the lock again.
*/
for (Session_view_list_elem *v = _view_list.first(); v; v = v->next()) {
try {
View &view = *static_cast<View *>(v);
if (_view_handle_registry.has_handle(view, handle)) {
_destroy_view(view);
break;
}
} catch (View_handle_registry::Lookup_failed) { }
}
catch (View_handle_registry::Lookup_failed) { }
_view_handle_registry.free(handle);
}