[PATCH 03/15] Shutdown devd process cleanly for tests

Valerie Aurora val at versity.com
Wed Mar 12 07:33:42 PDT 2025


The ngnfs tests send SIGUSR1 to the devd processes to shut them down,
which causes the io_get_events() system call to fail with EINVAL after
the socket has been closed by another thread. Replace the assert(ret >
0) with a clean exit on EINVAL and an assert() otherwise so we can
distinguish a clean shutdown from a bug.

Signed-off-by: Valerie Aurora <val at versity.com>
---
 devd/btr-aio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/devd/btr-aio.c b/devd/btr-aio.c
index c16f671..68cdbd0 100644
--- a/devd/btr-aio.c
+++ b/devd/btr-aio.c
@@ -124,7 +124,13 @@ static void getevents_thread(struct thread *thr, void *arg)
 
 		ret = syscall(__NR_io_getevents, ainf->ctx, 1, ainf->queue_depth,
 			      ainf->events, NULL);
-		assert(ret > 0);
+		if (ret < 0) {
+			/* socket closed by another thread, likely due to shutdown */
+			if (errno == EINVAL)
+				break;
+			assert(ret > 0);
+		}
+
 		nr = ret;
 
 		for (i = 0; i < nr; i++) {
-- 
2.48.1




More information about the ngnfs-devel mailing list