From d23ee02e9a3bfef65612e88fc41cc1353d3f5627 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Thu, 15 Nov 2012 12:49:08 +0100 Subject: [PATCH] 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. --- base-nova/src/base/server/server.cc | 14 ++++++++++++++ base/include/base/rpc_server.h | 2 ++ base/src/base/server/common.cc | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/base-nova/src/base/server/server.cc b/base-nova/src/base/server/server.cc index 998e4d4d61..869134adfb 100644 --- a/base-nova/src/base/server/server.cc +++ b/base-nova/src/base/server/server.cc @@ -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 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); + } +} diff --git a/base/include/base/rpc_server.h b/base/include/base/rpc_server.h index 68110c9f9f..6369b7efff 100644 --- a/base/include/base/rpc_server.h +++ b/base/include/base/rpc_server.h @@ -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 */ diff --git a/base/src/base/server/common.cc b/base/src/base/server/common.cc index 03b5c4f950..c7e52f2fa7 100644 --- a/base/src/base/server/common.cc +++ b/base/src/base/server/common.cc @@ -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 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(); +}