Skip to content

Commit

Permalink
Tidy up implementation and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 12, 2021
1 parent 26d8092 commit 7d581e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions ext/event/backend/uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,24 +421,24 @@ unsigned select_process_completions(struct io_uring *ring) {
unsigned head;
struct io_uring_cqe *cqe;

io_uring_for_each_cqe(ring, head, cqe) {
++completed;
// If the operation was cancelled, or the operation has no user data (fiber):
if (cqe->res == -ECANCELED || cqe->user_data == 0 || cqe->user_data == LIBURING_UDATA_TIMEOUT) {
continue;
}
VALUE fiber = (VALUE)cqe->user_data;
VALUE result = INT2NUM(cqe->res);
// fprintf(stderr, "cqe res=%d user_data=%p\n", cqe->res, (void*)cqe->user_data);
Event_Backend_transfer_result(fiber, result);
io_uring_for_each_cqe(ring, head, cqe) {
++completed;

// If the operation was cancelled, or the operation has no user data (fiber):
if (cqe->res == -ECANCELED || cqe->user_data == 0 || cqe->user_data == LIBURING_UDATA_TIMEOUT) {
continue;
}

VALUE fiber = (VALUE)cqe->user_data;
VALUE result = INT2NUM(cqe->res);

// fprintf(stderr, "cqe res=%d user_data=%p\n", cqe->res, (void*)cqe->user_data);

Event_Backend_transfer_result(fiber, result);
}

if (completed) {
io_uring_cq_advance(ring, completed);
io_uring_cq_advance(ring, completed);
}

return completed;
Expand Down
4 changes: 2 additions & 2 deletions spec/event/selector_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def now
sleep(1)

result = subject.process_wait(Fiber.current, pid, 0)
pp result
expect(result).to be_success
events << :process_finished
end

Expand All @@ -218,7 +218,7 @@ def now
fiber = Fiber.new do
pid = Process.spawn("sleep 1")
result = subject.process_wait(Fiber.current, pid, 0)
pp result
expect(result).to be_success
events << :process_finished
end

Expand Down

0 comments on commit 7d581e1

Please sign in to comment.