Skip to content

What happens if io_uring_get_sqe returns NULL? #68

Answered by ioquatix
ioquatix asked this question in Q&A
Discussion options

You must be logged in to vote
		struct io_uring_sqe *sqe = NULL;
		
		while (!sqe) {
			io_uring_get_sqe(&data->ring);
			rb_thread_schedule();
		}

This doesn't seem ideal. Can we assume that after calling io_uring_submit there will be sqe available in every case?

It also seems like we would encounter race condition.

if (data->polling) { // it's true because we called some io_uring blocking method
  sqe = ...
  
  // data->polling is now 0 or becomes zero during the next call
  io_uring_submit(...) // boom thread unsafe submit
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@noteflakes
Comment options

@ioquatix
Comment options

Answer selected by noteflakes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants