From: Jens Axboe <axboe@kernel.dk>
To: "Lukáš Lalinský" <lukas@lalinsky.com>
Cc: io-uring@vger.kernel.org
Subject: Re: io_uring: SENDMSG/WRITEV return -EAGAIN on O_NONBLOCK socket after peer half-close
Date: Tue, 3 Nov 2026 09:00:42 -0700 [thread overview]
Message-ID: <3face247-a7b6-4f87-9863-5ad40cc272a0@kernel.dk> (raw)
In-Reply-To: <5475728c-6cd9-4d61-bcee-5c8a42f1951d@app.fastmail.com>
On 11/2/26 7:00 AM, Luk?? Lalinsk? wrote:
> On Thu, Oct 29, 2026, at 9:42 PM, Luk?? Lalinsk? wrote:
>> There is one more inconsistency even with both patches applied:
>> in the urgent data case, WRITEV on an O_NONBLOCK socket still completes
>> with -EAGAIN, while SEND and SENDMSG on the same socket keep waiting.
>> So whether WRITEV waits or fails depends on whether the peer sent
>> urgent data, which the application can't really predict. It's not a
>> problem for me, since I always use SEND/SENDMSG on sockets, but it is
>> an inconsistent behavior.
>
> Hi Jens,
>
> I ran into one more issue while testing this. The SEND or SENDMSG
> operations become uncancelable for a brief time after submission,
> either in the half-closed state before your patches, or with the urgent
> data flag after your patches. If ASYNC_CANCEL is submitted right
> after the send on such socket, it completes with -ENOENT, but the
> send stays pending. A second cancel issued later finds it. Without the
> urgent data, the first cancel finds it and the send completes with
> -ECANCELED. Your patches made it work properly for the half-closed
> case.
Can you try with this on top?
diff --git a/io_uring/poll.c b/io_uring/poll.c
index ac2979586b4f..82485e1350dd 100644
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -739,7 +739,7 @@ int io_arm_apoll(struct io_kiocb *req, unsigned issue_flags, __poll_t mask)
int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
{
const struct io_issue_def *def = &io_issue_defs[req->opcode];
- __poll_t mask = POLLPRI | POLLERR;
+ __poll_t mask = EPOLLERR;
if (!def->pollin && !def->pollout)
return IO_APOLL_ABORTED;
@@ -747,7 +747,8 @@ int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
return IO_APOLL_ABORTED;
if (def->pollin) {
- mask |= EPOLLIN | EPOLLRDNORM;
+ /* urgent data is an event for a reader only */
+ mask |= EPOLLIN | EPOLLRDNORM | EPOLLPRI;
/* If reading from MSG_ERRQUEUE using recvmsg, ignore POLLIN */
if (req->flags & REQ_F_CLEAR_POLLIN)
--
Jens Axboe
next prev parent reply other threads:[~2026-11-03 16:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 18:54 io_uring: SENDMSG/WRITEV return -EAGAIN on O_NONBLOCK socket after peer half-close Lukáš Lalinský
2026-10-29 19:48 ` Jens Axboe
2026-10-29 20:42 ` Lukáš Lalinský
[not found] ` <5475728c-6cd9-4d61-bcee-5c8a42f1951d@app.fastmail.com>
2026-11-03 16:00 ` Jens Axboe [this message]
2026-11-06 12:04 ` Lukáš Lalinský
2026-11-06 23:54 ` Jens Axboe
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=3face247-a7b6-4f87-9863-5ad40cc272a0@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=lukas@lalinsky.com \
/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