public inbox for [email protected]
 help / color / mirror / Atom feed
From: Olivier Langlois <[email protected]>
To: [email protected]
Subject: Re: IOSQE_BUFFER_SELECT buffer returned even in case of failure?
Date: Thu, 10 Jun 2021 14:42:08 -0400	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On Wed, 2021-06-09 at 15:19 -0400, Olivier Langlois wrote:
> the man page says the following:
> 
>     If succesful, the resulting CQE will have IORING_CQE_F_BUFFER set
> in the flags part of the struct, and the upper
> IORING_CQE_BUFFER_SHIFT
> bits will contain the ID of the selected buffers.
> 
> based on my understanding of the kernel code (it could wrong. testing
> is still ongoing to be 100% sure), the buffer will be returned even
> if
> the underlying syscall fails. (I have only checked io_read() for
> IORING_OP_READ).
> 
> At the minimum, the man page should be clarified to better reflect
> the
> code behavior. (and there is a missing 's' in succesful)
> 
> ideally, imho, I believe the code should be modified to do what the
> man
> page says because:
> 
> 1. doing otherwise is counter-intuitive and error-prone (I cannot
> think
> of a single example of a syscall failing and still require the user
> to
> free the allocated resources)
> 
> 2. it is inefficient because the buffer is unneeded since there is no
> data to transfer back to the user and the buffer will need to be
> returned back to io_uring to avoid a leak.
> 
I have confirmed that a buffer was returned and needed to be provided
back io_uring even when read() syscall was failing.

It failed with ECONNRESET with obviously no data and I still had to
return back the buffer to avoid a leak (which my app was suffering of).

Unless someone says that it works as designed, I'll figure out a way to
fix that with a patch. It should be trivial to do.

Greetings,
Olivier



      reply	other threads:[~2021-06-10 18:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 19:19 IOSQE_BUFFER_SELECT buffer returned even in case of failure? Olivier Langlois
2021-06-10 18:42 ` Olivier Langlois [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b29a1ceb81ec91371fb1835eec4471c7254402e.camel@trillion01.com \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox