From 90c446e565e1ed77524a022c2776ca1c7575c58b Mon Sep 17 00:00:00 2001
From: Norman Feske <norman.feske@genode-labs.com>
Date: Mon, 24 Jan 2022 11:11:24 +0100
Subject: [PATCH] base-hw: remove throw from ipc_reply_wait

Even though the use of the C++ exception mechanism (and the implicit use
of the cxx heap) is not a problem at the server side, this patch
nevertheless replaces the exception-based return-value handling to make
the code consistent with the ipc_call path.

Issue #3612
---
 repos/base-hw/src/lib/base/ipc.cc | 33 +++++++++++++++----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/repos/base-hw/src/lib/base/ipc.cc b/repos/base-hw/src/lib/base/ipc.cc
index 8346e8e604..4990f6eccc 100644
--- a/repos/base-hw/src/lib/base/ipc.cc
+++ b/repos/base-hw/src/lib/base/ipc.cc
@@ -140,24 +140,23 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
 {
 	Native_utcb &utcb = *Thread::myself()->utcb();
 
-	retry<Genode::Allocator::Out_of_memory>(
-		[&] () {
-			int ret = 0;
-			if (exc.value != Rpc_exception_code::INVALID_OBJECT) {
-				copy_msg_to_utcb(reply_msg, utcb);
-				utcb.exception_code(exc.value);
-				ret = Kernel::send_reply_msg(Msgbuf_base::MAX_CAPS_PER_MSG, true);
-			} else {
-				ret = Kernel::await_request_msg(Msgbuf_base::MAX_CAPS_PER_MSG);
-			}
+	for (bool done = false; !done; ) {
 
-			switch (ret) {
-			case -1: throw Blocking_canceled();
-			case -2: throw Allocator::Out_of_memory();
-			default: break;
-			}
-		},
-		[&] () { upgrade_capability_slab(); });
+		int ret = 0;
+		if (exc.value != Rpc_exception_code::INVALID_OBJECT) {
+			copy_msg_to_utcb(reply_msg, utcb);
+			utcb.exception_code(exc.value);
+			ret = Kernel::send_reply_msg(Msgbuf_base::MAX_CAPS_PER_MSG, true);
+		} else {
+			ret = Kernel::await_request_msg(Msgbuf_base::MAX_CAPS_PER_MSG);
+		}
+
+		switch (ret) {
+		case -1: throw Blocking_canceled();
+		case -2: upgrade_capability_slab(); break;
+		default: done = true; break;
+		}
+	}
 
 	copy_utcb_to_msg(utcb, request_msg);