hare

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

commit 73ff7e51e34ad38536686140a275f8a783e96cb1
parent 015f00c39c5a82378034c491b213b568e7a22a48
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 20 Oct 2021 13:45:53 +0200

iobus: simplify busfile

Turns out this *does* work. Not sure what the issue was before.

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

Diffstat:
Mcmd/iobus/main.ha | 4++--
Miobus/io_uring/bus.ha | 15++-------------
2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/cmd/iobus/main.ha b/cmd/iobus/main.ha @@ -21,7 +21,8 @@ export fn main() void = { defer io::close(userfd); const in = iobus::register_file(mainbus, os::stdin_file); - // XXX: This seems to break polling? possible kernel bug + // XXX: io_uring has a somewhat arbitrary limitation on registering + // another uring as a file, so we can't do this. //const userfd = iobus::register_file(mainbus, userfd); let pollin = iobus::poll(mainbus, in, poll::event::POLLIN)!; @@ -54,7 +55,6 @@ export fn main() void = { }; if (iobus::handleof(res) == &polluser) { iobus::endpoll(mainbus, res)!; - iobus::busfile_drain(userfd); polluser = iobus::poll(mainbus, userfd, poll::event::POLLIN)!; iobus::enqueue(mainbus, &polluser); diff --git a/iobus/io_uring/bus.ha b/iobus/io_uring/bus.ha @@ -23,20 +23,9 @@ export fn destroy(bus: *bus) void = { io_uring::finish(&bus.uring); }; -// Returns an [[io::file]] for the bus itself. This file descriptor may be used -// with [[poll]], [[unix::poll]], etc, to determine when [[dispatch]] will -// return new I/O results. When this file is readable, the user must call -// [[busfile_drain]] to acknowledge this condition. +// Returns an [[io::file]] for the bus itself. export fn busfile(bus: *bus) io::file = { - let fd = rt::eventfd(0, 0)!; - io_uring::register_eventfd(&bus.uring, fd)!; - return fd; -}; - -// Drains a pending read from the [[busfile]]. -export fn busfile_drain(file: io::file) void = { - let count: [8]u8 = [0...]; - io::read(file, count)!; + return bus.uring.fd; }; // Registers a set of I/O operations with the queue, without submitting them.