Destruct IPC-server object on entrypoint destruction

The IPC-server object exists solely on the stack of the entrypoint
thread and, therefore, would never be destructed as the thread is just
killed. Now, the object is explicitly destructed in the entrypoint
destructor. An alternative solution could instruct the entrypoint thread
the terminate, which would automatically cleanup its stack.

The object pool is assumed to be empty on destruction of the entrypoint.
If not, we warn and at least dissolve all RPC objects.
This commit is contained in:
Christian Helmuth 2012-11-15 12:49:08 +01:00
parent 2cdac0eb32
commit d23ee02e9a
3 changed files with 32 additions and 0 deletions

View File

@ -254,3 +254,17 @@ Rpc_entrypoint::Rpc_entrypoint(Cap_session *cap_session, size_t stack_size,
if (start_on_construction)
activate();
}
Rpc_entrypoint::~Rpc_entrypoint()
{
typedef Object_pool<Rpc_object_base> Pool;
if (Pool::first()) {
PWRN("Object pool not empty in %s", __func__);
/* dissolve all objects - objects are not destroyed! */
while (Rpc_object_base *obj = Pool::first())
_dissolve(obj);
}
}

View File

@ -318,6 +318,8 @@ namespace Genode {
Rpc_entrypoint(Cap_session *cap_session, size_t stack_size,
char const *name, bool start_on_construction = true);
~Rpc_entrypoint();
/**
* Associate RPC object with the entry point
*/

View File

@ -104,3 +104,19 @@ Rpc_entrypoint::Rpc_entrypoint(Cap_session *cap_session, size_t stack_size,
if (start_on_construction)
activate();
}
Rpc_entrypoint::~Rpc_entrypoint()
{
typedef Object_pool<Rpc_object_base> Pool;
if (Pool::first()) {
PWRN("Object pool not empty in %s", __func__);
/* dissolve all objects - objects are not destroyed! */
while (Rpc_object_base *obj = Pool::first())
_dissolve(obj);
}
_ipc_server->~Ipc_server();
}