17c79a9e23
Besides adapting the components to the use of base/log.h, the patch cleans up a few base headers, i.e., it removes unused includes from root/component.h, specifically base/heap.h and ram_session/ram_session.h. Hence, components that relied on the implicit inclusion of those headers have to manually include those headers now. While adjusting the log messages, I repeatedly stumbled over the problem that printing char * arguments is ambiguous. It is unclear whether to print the argument as pointer or null-terminated string. To overcome this problem, the patch introduces a new type 'Cstring' that allows the caller to express that the argument should be handled as null-terminated string. As a nice side effect, with this type in place, the optional len argument of the 'String' class could be removed. Instead of supplying a pair of (char const *, size_t), the constructor accepts a 'Cstring'. This, in turn, clears the way let the 'String' constructor use the new output mechanism to assemble a string from multiple arguments (and thereby getting rid of snprintf within Genode in the near future). To enforce the explicit resolution of the char * ambiguity, the 'char *' overload of the 'print' function is marked as deleted. Issue #1987
114 lines
2.6 KiB
C++
114 lines
2.6 KiB
C++
/*
|
|
* \brief Platform-independent part of server-side RPC framework
|
|
* \author Norman Feske
|
|
* \date 2006-05-12
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2006-2013 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.
|
|
*/
|
|
|
|
/* Genode includes */
|
|
#include <base/rpc_server.h>
|
|
#include <base/rpc_client.h>
|
|
#include <base/blocking.h>
|
|
#include <base/env.h>
|
|
|
|
/* base-internal includes */
|
|
#include <base/internal/ipc_server.h>
|
|
#include <signal_source/signal_source.h>
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
void Rpc_entrypoint::_dissolve(Rpc_object_base *obj)
|
|
{
|
|
/* make sure nobody is able to find this object */
|
|
remove(obj);
|
|
|
|
_free_rpc_cap(_pd_session, obj->cap());
|
|
|
|
/* effectively invalidate the capability used before */
|
|
obj->cap(Untyped_capability());
|
|
|
|
/* now the object may be safely destructed */
|
|
}
|
|
|
|
|
|
void Rpc_entrypoint::_block_until_cap_valid()
|
|
{
|
|
_cap_valid.lock();
|
|
}
|
|
|
|
|
|
void Rpc_entrypoint::reply_signal_info(Untyped_capability reply_cap,
|
|
unsigned long imprint, unsigned long cnt)
|
|
{
|
|
Msgbuf<sizeof(Signal_source::Signal)> snd_buf;
|
|
snd_buf.insert(Signal_source::Signal(imprint, cnt));
|
|
ipc_reply(reply_cap, Rpc_exception_code(Rpc_exception_code::SUCCESS), snd_buf);
|
|
}
|
|
|
|
|
|
void Rpc_entrypoint::activate()
|
|
{
|
|
_delay_start.unlock();
|
|
}
|
|
|
|
|
|
bool Rpc_entrypoint::is_myself() const
|
|
{
|
|
return (Thread::myself() == this);
|
|
}
|
|
|
|
|
|
Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
|
|
char const *name, bool start_on_construction,
|
|
Affinity::Location location)
|
|
:
|
|
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size, location),
|
|
_cap(Untyped_capability()),
|
|
_cap_valid(Lock::LOCKED), _delay_start(Lock::LOCKED),
|
|
_delay_exit(Lock::LOCKED),
|
|
_pd_session(*pd_session)
|
|
{
|
|
Thread::start();
|
|
_block_until_cap_valid();
|
|
|
|
if (start_on_construction)
|
|
activate();
|
|
|
|
_exit_cap = manage(&_exit_handler);
|
|
}
|
|
|
|
|
|
Rpc_entrypoint::~Rpc_entrypoint()
|
|
{
|
|
/*
|
|
* We have to make sure the server loop is running which is only the case
|
|
* if the Rpc_entrypoint was actived before we execute the RPC call.
|
|
*/
|
|
_delay_start.unlock();
|
|
|
|
/* leave server loop */
|
|
_exit_cap.call<Exit::Rpc_exit>();
|
|
|
|
dissolve(&_exit_handler);
|
|
|
|
if (!empty())
|
|
warning("object pool not empty in ", __func__);
|
|
|
|
/*
|
|
* Now that we finished the 'dissolve' steps above (which need a working
|
|
* 'Ipc_server' in the context of the entrypoint thread), we can allow the
|
|
* entrypoint thread to leave the scope. Thereby, the 'Ipc_server' object
|
|
* will get destructed.
|
|
*/
|
|
_delay_exit.unlock();
|
|
|
|
join();
|
|
}
|