base: remove base/blocking.h

This patch removes the obsolete exception type 'Blocking_canceled'.

Issue #4768
This commit is contained in:
Norman Feske 2023-02-21 15:33:12 +01:00 committed by Christian Helmuth
parent 32f9d1fceb
commit 356506a67a
16 changed files with 33 additions and 93 deletions

View File

@ -14,7 +14,6 @@
/* Genode includes */
#include <base/log.h>
#include <base/ipc.h>
#include <base/blocking.h>
/* base-internal includes */
#include <base/internal/ipc_server.h>
@ -166,10 +165,6 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
rcv_header.extract_caps(rcv_msg);
if (L4_IPC_IS_ERROR(ipc_result)) {
if (L4_IPC_ERROR(ipc_result) == L4_IPC_RECANCELED)
throw Genode::Blocking_canceled();
error("ipc_call error ", Hex(L4_IPC_ERROR(ipc_result)));
throw Genode::Ipc_error();
}

View File

@ -21,10 +21,10 @@
*/
/* Genode includes */
#include <base/blocking.h>
#include <base/ipc.h>
#include <base/ipc_msgbuf.h>
#include <base/thread.h>
#include <base/sleep.h>
/* base-internal includes */
#include <base/internal/lock_helper.h> /* for 'thread_get_my_native_id()' */
@ -279,11 +279,10 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
l4_msgtag_t const reply_tag =
l4_ipc_call(dst.data()->kcap(), l4_utcb(), call_tag, L4_IPC_NEVER);
if (l4_ipc_error(reply_tag, l4_utcb()) == L4_IPC_RECANCELED)
throw Genode::Blocking_canceled();
if (ipc_error(reply_tag, DEBUG_MSG))
throw Genode::Ipc_error();
if (ipc_error(reply_tag, DEBUG_MSG)) {
raw("L4 IPC error");
sleep_forever();
}
return Rpc_exception_code(extract_msg_from_utcb(reply_tag, rcv_window, rcv_msg));
}

View File

@ -17,6 +17,7 @@
#include <base/ipc.h>
#include <base/allocator.h>
#include <base/thread.h>
#include <base/sleep.h>
#include <util/construct_at.h>
#include <util/retry.h>
@ -106,7 +107,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
switch (Kernel::send_request_msg(Capability_space::capid(dst),
(unsigned)rcv_caps)) {
case -1: throw Blocking_canceled();
case -1: sleep_forever();
case -2: upgrade_capability_slab(); break;
default: done = true; break;
}
@ -152,7 +153,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
}
switch (ret) {
case -1: throw Blocking_canceled();
case -1: sleep_forever();
case -2: upgrade_capability_slab(); break;
default: done = true; break;
}

View File

@ -17,7 +17,6 @@
/* Genode includes */
#include <base/ipc.h>
#include <base/thread.h>
#include <base/blocking.h>
#include <base/env.h>
#include <base/sleep.h>
#include <linux_native_cpu/linux_native_cpu.h>
@ -326,7 +325,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
int const send_ret = lx_sendmsg(dst_socket, snd_msg.msg(), 0);
if (send_ret < 0) {
error(lx_getpid(), ":", lx_gettid(), " lx_sendmsg to sd ", dst_socket,
" failed with ", send_ret, " in lx_call()");
" failed with ", send_ret, " in lx_call()");
sleep_forever();
}
@ -339,14 +338,19 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
rcv_msg.accept_sockets(Message::MAX_SDS_PER_MSG);
rcv_msgbuf.reset();
int const recv_ret = lx_recvmsg(reply_channel.local, rcv_msg.msg(), 0);
/* system call got interrupted by a signal */
if (recv_ret == -LX_EINTR)
throw Genode::Blocking_canceled();
for (;;) {
int const recv_ret = lx_recvmsg(reply_channel.local, rcv_msg.msg(), 0);
if (recv_ret < 0) {
error(lx_getpid(), ":", lx_gettid(), " ipc_call failed to receive result (", recv_ret, ")");
/* system call got interrupted by a signal */
if (recv_ret == -LX_EINTR)
continue;
if (recv_ret >= 0)
break;
error(lx_getpid(), ":", lx_gettid(),
" ipc_call failed to receive result (", recv_ret, ")");
sleep_forever();
}

View File

@ -47,6 +47,5 @@ void Timer::Time_source::_usleep(uint64_t us)
ts.tv_sec = (long)us / (1000 * 1000);
ts.tv_nsec = ((long)us % (1000 * 1000)) * 1000;
if (lx_nanosleep(&ts, &ts) != 0)
throw Blocking_canceled();
lx_nanosleep(&ts, &ts);
}

View File

@ -157,7 +157,8 @@ void Rpc_entrypoint::_activation_entry()
}
/* atomically lookup and lock referenced object */
auto lambda = [&] (Rpc_object_base *obj) {
auto lambda = [&] (Rpc_object_base *obj)
{
if (!obj) {
error("could not look up server object, return from call id_pt=", id_pt);
return;
@ -165,8 +166,7 @@ void Rpc_entrypoint::_activation_entry()
/* dispatch request */
ep._snd_buf.reset();
try { exc = obj->dispatch(opcode, unmarshaller, ep._snd_buf); }
catch (Blocking_canceled) { }
exc = obj->dispatch(opcode, unmarshaller, ep._snd_buf);
};
ep.apply(id_pt, lambda);

View File

@ -14,7 +14,7 @@
/* Genode includes */
#include <base/log.h>
#include <base/ipc.h>
#include <base/blocking.h>
#include <base/sleep.h>
/* base-internal includes */
#include <base/internal/ipc_server.h>
@ -162,15 +162,9 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
L4_MsgTag_t rcv_tag = L4_Call(dst_data.dst);
enum { ERROR_MASK = 0xe, ERROR_CANCELED = 3 << 1 };
if (L4_IpcFailed(rcv_tag) &&
((L4_ErrorCode() & ERROR_MASK) == ERROR_CANCELED))
throw Genode::Blocking_canceled();
if (L4_IpcFailed(rcv_tag)) {
raw("Ipc failed");
return Rpc_exception_code(Rpc_exception_code::INVALID_OBJECT);
sleep_forever();
}
return Rpc_exception_code(extract_msg_from_utcb(rcv_tag, rcv_msg));

View File

@ -15,7 +15,6 @@
/* Genode includes */
#include <base/log.h>
#include <base/ipc.h>
#include <base/blocking.h>
#include <base/sleep.h>
/* base-internal includes */
@ -32,26 +31,18 @@ using namespace Pistachio;
*/
static inline void check_ipc_result(L4_MsgTag_t result, L4_Word_t error_code)
{
/*
* Test for IPC cancellation via Core's cancel-blocking mechanism
*/
enum { ERROR_MASK = 0xe, ERROR_CANCELED = 3 << 1 };
if (L4_IpcFailed(result) &&
((L4_ErrorCode() & ERROR_MASK) == ERROR_CANCELED))
throw Genode::Blocking_canceled();
/*
* Provide diagnostic information on unexpected conditions
*/
if (L4_IpcFailed(result)) {
raw("Error in thread ", Hex(L4_Myself().raw), ". IPC failed.");
throw Genode::Ipc_error();
throw Ipc_error();
}
if (L4_UntypedWords(result) < 2) {
raw("Error in thread ", Hex(L4_Myself().raw), ". "
"Expected at leat two untyped words, but got ", L4_UntypedWords(result), ".\n");
throw Genode::Ipc_error();
throw Ipc_error();
}
}

View File

@ -12,7 +12,6 @@
*/
/* Genode includes */
#include <base/blocking.h>
#include <base/ipc.h>
#include <base/log.h>
#include <base/thread.h>

View File

@ -1,31 +0,0 @@
/*
* \brief Support for blocking operations
* \author Norman Feske
* \date 2007-09-06
*/
/*
* Copyright (C) 2007-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _INCLUDE__BASE__BLOCKING_H_
#define _INCLUDE__BASE__BLOCKING_H_
#include <base/exception.h>
namespace Genode { class Blocking_canceled; }
/**
* Blocking-canceled exception
*
* Two operations may block a thread, waiting at a lock or performing an RPC
* call. Both operations may be canceled when the thread is destructed. In this
* case, the thread unblocks and throws an exception, and therefore, is able to
* clean up the thread state before exiting.
*/
class Genode::Blocking_canceled : public Exception { };
#endif /* _INCLUDE__BASE__BLOCKING_H_ */

View File

@ -30,7 +30,6 @@ namespace Genode {
* Invoke capability to call an RPC function
*
* \param rcv_caps number of capabilities expected as result
* \throw Blocking_canceled
*
* \noapi
*

View File

@ -15,7 +15,6 @@
#define _INCLUDE__BASE__LOCK_H_
#include <base/lock_guard.h>
#include <base/blocking.h>
namespace Genode {
class Lock;

View File

@ -134,9 +134,7 @@ void Entrypoint::_process_incoming_signals()
* as result, which has to be caught.
*/
try {
retry<Blocking_canceled>(
[&] () { _signal_proxy_cap.call<Signal_proxy::Rpc_signal>(); },
[] () { warning("blocking canceled during signal processing"); });
_signal_proxy_cap.call<Signal_proxy::Rpc_signal>();
} catch (Genode::Ipc_error) { /* ignore - context got destroyed in meantime */ }
/* entrypoint destructor requested to stop signal handling */
@ -345,11 +343,7 @@ Entrypoint::Entrypoint(Env &env)
_env.ep().manage(constructor);
try {
invoke_constructor_at_entrypoint(constructor.cap());
} catch (Blocking_canceled) {
warning("blocking canceled in entrypoint constructor");
}
invoke_constructor_at_entrypoint(constructor.cap());
_env.ep().dissolve(constructor);

View File

@ -67,9 +67,8 @@ void Rpc_entrypoint::entry()
apply(request.badge, [&] (Rpc_object_base *obj)
{
if (!obj) { return;}
try { exc = obj->dispatch(opcode, unmarshaller, _snd_buf); }
catch(Blocking_canceled&) { }
if (obj)
exc = obj->dispatch(opcode, unmarshaller, _snd_buf);
});
}

View File

@ -14,7 +14,6 @@
/* Genode includes */
#include <base/rpc_server.h>
#include <base/rpc_client.h>
#include <base/blocking.h>
#include <base/env.h>
/* base-internal includes */

View File

@ -36,8 +36,7 @@ Timer::Time_source::_wait_for_irq()
while (_next_timeout_us > 0) {
_mutex.release();
try { _usleep(SLEEP_GRANULARITY_US); }
catch (Blocking_canceled) { }
_usleep(SLEEP_GRANULARITY_US);
uint64_t curr_time_us = curr_time().trunc_to_plain_us().value;
uint64_t sleep_duration_us = curr_time_us - last_time_us;