From f5906cb67b8b45ad6a57153279b9e3afc83a8a4c Mon Sep 17 00:00:00 2001
From: Florian Fischer <florian.fischer@muhq.space>
Date: Thu, 26 Aug 2021 16:29:42 +0200
Subject: [PATCH] [IoContext] die when the completer threads reaps new work
 notifications

The PipeSleepStrategy uses the invariant that the completer thread
is not reaping IoContext of workers which have a read of the
sleep/notification pipe in flight.
This means that it can not reap CQEs resulting from such reads.
To esnure this invariant we DIE if the completer encounters completions
for such notifications.
---
 emper/io/IoContext.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emper/io/IoContext.cpp b/emper/io/IoContext.cpp
index b0585437..44cff730 100644
--- a/emper/io/IoContext.cpp
+++ b/emper/io/IoContext.cpp
@@ -318,8 +318,11 @@ reap_cqes:
 		switch (tag) {
 			case PointerTags::NewWorkWsq:
 			case PointerTags::NewWorkAq: {
-				LOGD("Got new work notification");
+				if constexpr (callerEnvironment == CallerEnvironment::ANYWHERE) {
+					DIE_MSG("Completer reaping new work notification");
+				}
 
+				LOGD("Got new work notification");
 				auto *pipeSleepStrategy =
 						reinterpret_cast<PipeSleepStrategy *>(&runtime.getWorkerSleepStrategy());
 				statsIncr(pipeSleepStrategy->stats->wakeupDueToNotify);
-- 
GitLab