8b09418e56
Replacing the local name of a capability index object which exists in the capability map can destroy the AVL tree order of the capability map. With this patch the outdated object gets removed from the map and a new object gets inserted afterwards. Fixes #435.
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
/*
|
|
* \brief Obtain parent capability
|
|
* \author Norman Feske
|
|
* \date 2010-01-26
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2010-2012 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU General Public License version 2.
|
|
*/
|
|
|
|
#ifndef _PLATFORM__MAIN_PARENT_CAP_H_
|
|
#define _PLATFORM__MAIN_PARENT_CAP_H_
|
|
|
|
#include <base/native_types.h>
|
|
|
|
namespace Genode {
|
|
|
|
/**
|
|
* Return constructed parent capability
|
|
*/
|
|
Parent_capability parent_cap()
|
|
{
|
|
Native_capability::Raw *raw = (Native_capability::Raw *)&_parent_cap;
|
|
|
|
static Cap_index *i = cap_map()->insert(raw->local_name,
|
|
Fiasco::PARENT_CAP);
|
|
|
|
/*
|
|
* Update local name after a parent capability got reloaded via
|
|
* 'Platform_env::reload_parent_cap()'.
|
|
*/
|
|
if (i->id() != raw->local_name) {
|
|
cap_map()->remove(i);
|
|
i = cap_map()->insert(raw->local_name, Fiasco::PARENT_CAP);
|
|
}
|
|
|
|
return reinterpret_cap_cast<Parent>(Native_capability(i));
|
|
}
|
|
}
|
|
|
|
#endif /* _PLATFORM__MAIN_PARENT_CAP_H_ */
|