From: Hrvoje Zeba <[email protected]>
To: [email protected]
Subject: recvmsg not honoring O_NONBLOCK
Date: Sat, 9 Jul 2022 10:21:48 -0400 [thread overview]
Message-ID: <CAEsUgYg5zx5Zk_wp9=YXf5Y+qPh9vx7adDN=B_rpa3zoh2YSew@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 450 bytes --]
Hi folks,
I was adapting msquic library to work with iouring and found an issue
with recvmsg() where it ignores O_NONBLOCK flag set on the file
descriptor. If MSG_DONTWAIT is set in flags, it behaves as expected.
I've attached a simple test which currently just hangs on iouring's
recvmsg(). I'm guessing sendmsg() behaves the same way but I have no
idea how to fill the buffer to reliably test it.
Best,
Hrvoje
--
I doubt, therefore I might be.
[-- Attachment #2: recvmsg_test.c --]
[-- Type: text/x-csrc, Size: 1781 bytes --]
#include <stdio.h>
#include <assert.h>
#include <liburing.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/udp.h>
void recvmsg_syscall(int s)
{
struct sockaddr_in addr;
char buff[1024];
struct iovec iov = {
.iov_base = buff,
.iov_len = sizeof(buff)
};
struct msghdr msg = {
.msg_name = &addr,
.msg_namelen = sizeof(addr),
.msg_iov = &iov,
.msg_iovlen = 1,
};
int res = recvmsg(s, &msg, 0/*MSG_DONTWAIT*/);
assert(res == -1);
assert(errno == EAGAIN);
}
void recvmsg_iouring(int s)
{
struct sockaddr_in addr;
char buff[1024];
struct iovec iov = {
.iov_base = buff,
.iov_len = sizeof(buff)
};
struct msghdr msg = {
.msg_name = &addr,
.msg_namelen = sizeof(addr),
.msg_iov = &iov,
.msg_iovlen = 1,
};
struct io_uring ring;
int res = io_uring_queue_init(1024, &ring, 0);
assert(res == 0);
struct io_uring_cqe *cqe;
struct io_uring_sqe* sqe;
sqe = io_uring_get_sqe(&ring);
io_uring_prep_recvmsg(sqe, s, &msg, 0/*MSG_DONTWAIT*/);
res = io_uring_submit(&ring);
assert(res == 1);
res = io_uring_wait_cqe(&ring, &cqe);
assert(res == 0);
assert(cqe->res == -EAGAIN);
io_uring_cqe_seen(&ring, cqe);
io_uring_queue_exit(&ring);
}
int main(int argc, const char* argv[])
{
int s = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
assert(s != -1);
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_port = 0x0010,
.sin_addr.s_addr = 0x0100007fUL
};
int res = bind(s, (struct sockaddr*)(&addr), sizeof(addr));
assert(res == 0);
recvmsg_syscall(s);
recvmsg_iouring(s);
return 0;
}
next reply other threads:[~2022-07-09 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-09 14:21 Hrvoje Zeba [this message]
2022-07-09 15:25 ` recvmsg not honoring O_NONBLOCK Jens Axboe
2022-07-09 16:46 ` Hrvoje Zeba
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='CAEsUgYg5zx5Zk_wp9=YXf5Y+qPh9vx7adDN=B_rpa3zoh2YSew@mail.gmail.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