From c896660c44de4f1840c90ca5f2d488e440c6c7f6 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 22 Oct 2021 09:51:57 +0200 Subject: [PATCH] iobus: implement nobuffers error Signed-off-by: Drew DeVault --- io_uring/cqe.ha | 14 +++++++++++--- diff --git a/io_uring/cqe.ha b/io_uring/cqe.ha index 22116fd7a2c32c2197a35804a2ecedca7af22f27..b14d21bf89fa818f1992057ffaf91719d754afba 100644 --- a/io_uring/cqe.ha +++ b/io_uring/cqe.ha @@ -28,9 +28,17 @@ // queue. export fn peek(ring: *io_uring) (nullable *cqe | error) = get_cqe(ring, 0, 0); // Returns the result of a [[cqe]], or an error if unsuccessful. -export fn result(cqe: *cqe) (int | error) = - if (cqe.res < 0) errors::errno(rt::wrap_errno(-cqe.res)) - else cqe.res; +export fn result(cqe: *cqe) (int | error) = { + if (cqe.res >= 0) { + return cqe.res; + }; + switch (-cqe.res) { + case rt::ENOBUFS => + return nobuffers; + case => + return errors::errno(rt::wrap_errno(-cqe.res)); + }; +}; // Gets the user data field of a [[cqe]]. See [[set_user]] for the corresponding // SQE function. -- 2.48.1