summaryrefslogtreecommitdiff
path: root/uring.c
diff options
context:
space:
mode:
Diffstat (limited to 'uring.c')
-rw-r--r--uring.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/uring.c b/uring.c
index 20d8234..9dcdcf6 100644
--- a/uring.c
+++ b/uring.c
@@ -257,6 +257,43 @@ uring_accept(struct cfg *cfg, struct uring_task *task, struct sockaddr_in46 *add
}
void
+uring_poll(struct cfg *cfg, struct uring_task *task, short poll_mask, callback_t callback)
+{
+ struct io_uring_sqe *sqe = io_uring_get_sqe(&cfg->uev->uring);
+
+ if (!sqe)
+ perrordie("io_uring_sqe");
+
+ if (task->fd < 0) {
+ error("uring_poll called with no fd set\n");
+ return;
+ }
+
+ uring_task_get(cfg, task);
+ task->callback = callback;
+ io_uring_prep_poll_add(sqe, task->fd, poll_mask);
+ io_uring_sqe_set_data(sqe, task);
+}
+
+void
+uring_poll_cancel(struct cfg *cfg, struct uring_task *task)
+{
+ struct io_uring_sqe *sqe = io_uring_get_sqe(&cfg->uev->uring);
+
+ if (!sqe)
+ perrordie("io_uring_sqe");
+
+ if (task->fd < 0) {
+ error("uring_poll_cancel called with no fd set\n");
+ return;
+ }
+
+ task->dead = true;
+ io_uring_prep_poll_remove(sqe, task);
+ io_uring_sqe_set_data(sqe, NULL);
+}
+
+void
uring_cancel(struct cfg *cfg, struct uring_task *task)
{
struct io_uring_sqe *sqe = io_uring_get_sqe(&cfg->uev->uring);