public inbox for [email protected]
 help / color / mirror / Atom feed
* RWF_NOWAIT does not work on socket
@ 2022-05-27  3:49 Xiaoguang Wang
  0 siblings, 0 replies; only message in thread
From: Xiaoguang Wang @ 2022-05-27  3:49 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, Christoph Hellwig, Pavel Begunkov, joeylee.lz

hi,

Now we're using io_uring's multi-shot feature,  multi-shot is similar
to epoll's edge-triggered mode, that means once one pure poll
request returns one event(cqe), we'll need to read or write continually
until EAGAIN is returned, which needs to set file to be non-blocking.

But since commit "io_uring: allow retry for O_NONBLOCK if async is
supported", seems that the non-blocking behavior has been changed.
In io_prep_rw:
+       /*
+        * If the file is marked O_NONBLOCK, still allow retry for it if it
+        * supports async. Otherwise it's impossible to use O_NONBLOCK files
+        * reliably. If not, or it IOCB_NOWAIT is set, don't retry.
+        */
+       if ((kiocb->ki_flags & IOCB_NOWAIT) ||
+           ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req, rw)))
                req->flags |= REQ_F_NOWAIT;

Then I tried to use RWF_NOWAIT, seems that it also does not work. In
kiocb_set_rw_flags():
    if (flags & RWF_NOWAIT) {
                if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
                        return -EOPNOTSUPP;
                kiocb_flags |= IOCB_NOIO;
        }

Seems that socket file doesn't have FMODE_NOWAIT set, so user apps
will get EOPNOTSUPP when using RWF_NOWAIT on socket. Also in
above codes, seems IOCB_NOWAIT isn't flagged too.

Any special reasons about above codes? Thanks.

Regards,
Xiaoguang Wang

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-27  3:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-27  3:49 RWF_NOWAIT does not work on socket Xiaoguang Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox