summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-10-01 08:58:17 -0600
committerJens Axboe <axboe@kernel.dk>2019-10-01 08:58:17 -0600
commitf6c8044fd0d4fb8b8b2136d3329b38576a706308 (patch)
tree464a5d87d72a87a2978b2d0505015b9d11ed49de /src
parent2529a2843fea388054ca9558fccaef91c8b410f2 (diff)
downloadliburing-f6c8044fd0d4fb8b8b2136d3329b38576a706308.tar.gz
liburing-f6c8044fd0d4fb8b8b2136d3329b38576a706308.tar.bz2
Fix timeout detection
We lost the -ETIME return from a previous commit that optimized the exported peek/wait cqe path, make sure that it works again. Fixes: 20c929379461 ("Inline fast-path of io_uring_{wait,peek}_cqe()") Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src')
-rw-r--r--src/include/liburing.h21
-rw-r--r--src/queue.c5
2 files changed, 16 insertions, 10 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 9ea4ba9..a99a681 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -260,7 +260,7 @@ static inline unsigned io_uring_cq_ready(struct io_uring *ring)
return io_uring_smp_load_acquire(ring->cq.ktail) - *ring->cq.khead;
}
-static struct io_uring_cqe *__io_uring_peek_cqe(struct io_uring *ring)
+static int __io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
{
struct io_uring_cqe *cqe;
unsigned head;
@@ -282,7 +282,8 @@ static struct io_uring_cqe *__io_uring_peek_cqe(struct io_uring *ring)
break;
} while (1);
- return cqe;
+ *cqe_ptr = cqe;
+ return err;
}
/*
@@ -292,9 +293,11 @@ static struct io_uring_cqe *__io_uring_peek_cqe(struct io_uring *ring)
static inline int io_uring_peek_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr)
{
- *cqe_ptr = __io_uring_peek_cqe(ring);
- if (*cqe_ptr)
- return 0;
+ int err;
+
+ err = __io_uring_peek_cqe(ring, cqe_ptr);
+ if (err)
+ return err;
return __io_uring_get_cqe(ring, cqe_ptr, 0, 0, NULL);
}
@@ -306,9 +309,11 @@ static inline int io_uring_peek_cqe(struct io_uring *ring,
static inline int io_uring_wait_cqe(struct io_uring *ring,
struct io_uring_cqe **cqe_ptr)
{
- *cqe_ptr = __io_uring_peek_cqe(ring);
- if (*cqe_ptr)
- return 0;
+ int err;
+
+ err = __io_uring_peek_cqe(ring, cqe_ptr);
+ if (err)
+ return err;
return __io_uring_get_cqe(ring, cqe_ptr, 0, 1, NULL);
}
diff --git a/src/queue.c b/src/queue.c
index b7d1acd..2caea87 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -17,8 +17,8 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
int ret, err = 0;
do {
- *cqe_ptr = __io_uring_peek_cqe(ring);
- if (*cqe_ptr)
+ err = __io_uring_peek_cqe(ring, cqe_ptr);
+ if (err || *cqe_ptr)
break;
if (!wait_nr) {
err = -EAGAIN;
@@ -28,6 +28,7 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr,
IORING_ENTER_GETEVENTS, sigmask);
if (ret < 0)
err = -errno;
+ submit -= ret;
} while (!err);
return err;