hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit e5c234e3ff6bba4530951d4dcc2efc525a6961f2
parent 36c8a0874ea5fcc71de9decfab16981172c34727
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 25 Oct 2021 10:12:01 +0200

iobus: clarify error behavior of [[getbuffer]]

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Miobus/io_uring/pool.ha | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/iobus/io_uring/pool.ha b/iobus/io_uring/pool.ha @@ -49,6 +49,11 @@ export fn setpool(handle: *handle, pool: pool) void = { // caller should provide the buffer from the return value to [[release]] when // done to return it to the host for future requests. After calling [[release]], // the slice reference is no longer valid. +// +// Note that I/O operations which completed with an error condition will not +// have a buffer assigned, even if [[setpool]] was called for the original +// handle. You must test for errors prior to calling [[getbuffer]] to avoid an +// assertion failure. export fn getbuffer(pool: *pool, result: result) (buffer, []u8) = { let buf: buffer = io_uring::get_buffer_id(result); return (buf, pool.buffer[(buf * pool.bufsz)..((buf + 1) * pool.bufsz)]);