Skip to content

Commit

Permalink
examples/kdigest: remove "error" handling
Browse files Browse the repository at this point in the history
There's on way the request will return -ECANCELED without being
explicitly canceled, which the example doesn't do, or the ring being
torn down. Just remove the attempted error handling here, as it's
incomplete/broken and it's better to have none (and just abort) than
broken error handling in what serves as an example.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Oct 1, 2024
1 parent 73a7003 commit 065b1ff
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions examples/kdigest.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,45 +75,32 @@ static int reap_completions(struct io_uring *ring, int *inflight,
{
struct io_uring_cqe *cqe;
unsigned head;
int ret, nr;
int ret = 0, nr;

nr = 0;
io_uring_for_each_cqe(ring, head, cqe) {
struct req *req;

req = io_uring_cqe_get_data(cqe);
assert(req->state == IO_READ || req->state == IO_WRITE);
ret = cqe->res;
if (ret < 0) {
if (ret == -ECANCELED && req->state == IO_READ) {
struct io_uring_sqe *sqe;

fprintf(stderr, "canceled read@%lld\n",
(long long)req->offset);
sqe = io_uring_get_sqe(ring);
io_uring_prep_read(sqe, infd,
req->iov.iov_base,
req->iov.iov_len, req->offset);
io_uring_sqe_set_data(sqe, req);
if (io_uring_submit(ring) < 0)
return 1;
continue;
} else {
fprintf(stderr, "cqe error: %s\n",
strerror(-ret));
return 1;
}
if (cqe->res < 0) {
fprintf(stderr, "%s: cqe error %d\n",
req->state == IO_WRITE ? "send" : "read",
cqe->res);
*outsize = 0;
ret = 1;
break;
}

(*inflight)--;
req->state++;
if (req->state == IO_WRITE_COMPLETE)
*outsize -= ret;
*outsize -= cqe->res;
nr++;
}

io_uring_cq_advance(ring, nr);
return 0;
return ret;
}

static void submit_sends_br(struct kdigest *kdigest, int *write_idx,
Expand Down

0 comments on commit 065b1ff

Please sign in to comment.