hw: throw expressive exceptions in signal session

ref #912
This commit is contained in:
Martin Stein 2013-10-14 10:38:51 +02:00 committed by Norman Feske
parent 04cbee4c76
commit bb9fa16a5e
2 changed files with 23 additions and 15 deletions

View File

@ -41,7 +41,11 @@ namespace Genode
*/
struct Signal_session : Session
{
class Out_of_metadata : public Exception { };
class Out_of_metadata : public Exception { };
class Create_receiver_failed : public Exception { };
class Create_context_failed : public Exception { };
class Kill_receiver_failed : public Exception { };
class Kill_context_failed : public Exception { };
/**
* String that can be used to refer to this service
@ -50,6 +54,9 @@ namespace Genode
/**
* Destructor
*
* \throw Kill_context_failed
* \throw Kill_receiver_failed
*/
virtual ~Signal_session() { }
@ -59,7 +66,7 @@ namespace Genode
* \return a cap that acts as reference to the created object
*
* \throw Out_of_metadata
* \throw Exception
* \throw Create_receiver_failed
*/
virtual Signal_receiver_capability alloc_receiver() = 0;
@ -74,7 +81,7 @@ namespace Genode
* \return a cap that acts as reference to the created object
*
* \throw Out_of_metadata
* \throw Exception
* \throw Create_context_failed
*/
virtual Signal_context_capability
alloc_context(Signal_receiver_capability r,
@ -85,7 +92,7 @@ namespace Genode
*
* \param cap capability of targeted signal receiver
*
* \throw Exception
* \throw Kill_receiver_failed
*/
virtual void free_receiver(Signal_receiver_capability cap) = 0;
@ -94,7 +101,7 @@ namespace Genode
*
* \param cap capability of targeted signal context
*
* \throw Exception
* \throw Kill_context_failed
*/
virtual void free_context(Signal_context_capability cap) = 0;
@ -105,18 +112,19 @@ namespace Genode
GENODE_RPC_THROW(Rpc_alloc_receiver, Signal_receiver_capability,
alloc_receiver, GENODE_TYPE_LIST(Out_of_metadata,
Exception));
Create_receiver_failed));
GENODE_RPC_THROW(Rpc_alloc_context, Signal_context_capability,
alloc_context, GENODE_TYPE_LIST(Out_of_metadata,
Exception), Signal_receiver_capability, unsigned);
Create_context_failed), Signal_receiver_capability,
unsigned);
GENODE_RPC_THROW(Rpc_free_receiver, void, free_receiver,
GENODE_TYPE_LIST(Exception),
GENODE_TYPE_LIST(Kill_receiver_failed),
Signal_receiver_capability);
GENODE_RPC_THROW(Rpc_free_context, void, free_context,
GENODE_TYPE_LIST(Exception),
GENODE_TYPE_LIST(Kill_context_failed),
Signal_context_capability);
GENODE_RPC_INTERFACE(Rpc_alloc_receiver, Rpc_alloc_context,

View File

@ -68,7 +68,7 @@ Signal_receiver_capability Signal_session_component::alloc_receiver()
/* clean up */
_receivers_slab.free(p, Receiver::slab_size());
PERR("failed to create signal receiver");
throw Exception();
throw Create_receiver_failed();
}
/* remember receiver ressources */
Native_capability cap(id, id);
@ -86,7 +86,7 @@ void Signal_session_component::free_receiver(Signal_receiver_capability cap)
Receiver * const r = _receivers.lookup_and_lock(cap);
if (!r) {
PERR("unknown signal receiver");
throw Exception();
throw Kill_receiver_failed();
}
/* release resources */
_destruct_receiver(r);
@ -112,7 +112,7 @@ Signal_session_component::alloc_context(Signal_receiver_capability r,
/* clean up */
_contexts_slab.free(p, Context::slab_size());
PERR("failed to create signal context");
throw Exception();
throw Create_context_failed();
}
/* remember context ressources */
Native_capability cap(id, id);
@ -129,7 +129,7 @@ void Signal_session_component::free_context(Signal_context_capability cap)
Context * const c = _contexts.lookup_and_lock(cap);
if (!c) {
PERR("unknown signal context");
throw Exception();
throw Kill_context_failed();
}
/* release resources */
_destruct_context(c);
@ -145,7 +145,7 @@ void Signal_session_component::_destruct_context(Context * const c)
/* clean-up */
c->release();
PERR("failed to kill signal context");
throw Exception();
throw Kill_context_failed();
}
/* release core resources */
_contexts.remove_locked(c);
@ -161,7 +161,7 @@ void Signal_session_component::_destruct_receiver(Receiver * const r)
/* clean-up */
r->release();
PERR("failed to kill signal receiver");
throw Exception();
throw Kill_receiver_failed();
}
/* release core resources */
_receivers.remove_locked(r);