From: Peter Xu <peterx@redhat.com>
To: Leonardo Bras Soares Passos <leobras@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
"Jason Wang" <jasowang@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Juan Quintela" <quintela@redhat.com>
Subject: Re: [PATCH v3 2/3] QIOChannelSocket: Implement io_async_write & io_async_flush
Date: Wed, 29 Sep 2021 15:58:56 -0400 [thread overview]
Message-ID: <YVTFgJoxbT4cTn4i@t490s> (raw)
In-Reply-To: <CAJ6HWG5tqm9eg3XzKF-M5nVFSkO9u5NVyUA7uxo8rC3bdZv_zA@mail.gmail.com>
On Wed, Sep 29, 2021 at 04:36:10PM -0300, Leonardo Bras Soares Passos wrote:
> On Tue, Sep 28, 2021 at 7:45 PM Peter Xu <peterx@redhat.com> wrote:
> >
> > On Wed, Sep 22, 2021 at 07:24:22PM -0300, Leonardo Bras wrote:
> > > +static void qio_channel_socket_async_flush(QIOChannel *ioc,
> > > + Error **errp)
> > > +{
> > > + QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
> > > + struct msghdr msg = {};
> > > + struct pollfd pfd;
> > > + struct sock_extended_err *serr;
> > > + struct cmsghdr *cm;
> > > + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)];
> > > + int ret;
> > > +
> > > + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS));
> > > + msg.msg_control = control;
> > > + msg.msg_controllen = sizeof(control);
> > > +
> > > + while (sioc->async_sent < sioc->async_queued) {
> > > + ret = recvmsg(sioc->fd, &msg, MSG_ERRQUEUE);
> > > + if (ret < 0) {
> > > + if (errno == EAGAIN) {
> > > + /* Nothing on errqueue, wait */
> > > + pfd.fd = sioc->fd;
> > > + pfd.events = 0;
> > > + ret = poll(&pfd, 1, 250);
> > > + if (ret == 0) {
> > > + /*
> > > + * Timeout : After 250ms without receiving any zerocopy
> > > + * notification, consider all data as sent.
> > > + */
> > > + break;
> >
> > After a timeout, we'll break the while loop and continue parsing an invalid
> > msg [1]. Is that what we want?
>
> No, the point here was returning from flush if this (long) timeout
> happened, as in
> "if asso long has passed, there must be no pending send", which I
> agree is quite bad,
> but it was all I could think to avoid an infinite loop here if
> something goes wrong.
IMHO it's the same when we write() to a socket but the buffer is always full,
we'll simply block there until it has some space. I don't know what we can do
here besides infinite loop on the timeout - we shouldn't eat the cpu all, but
we should still wait?
--
Peter Xu
next prev parent reply other threads:[~2021-09-29 20:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-22 22:24 [PATCH v3 0/3] QIOChannel async_write & async_flush + MSG_ZEROCOPY + multifd Leonardo Bras
2021-09-22 22:24 ` [PATCH v3 1/3] QIOChannel: Add io_async_writev & io_async_flush callbacks Leonardo Bras
2021-09-24 17:16 ` Daniel P. Berrangé
2021-09-28 21:52 ` Peter Xu
2021-09-29 19:06 ` Leonardo Bras Soares Passos
2021-09-30 8:34 ` Daniel P. Berrangé
2021-09-29 19:03 ` Leonardo Bras Soares Passos
2021-09-22 22:24 ` [PATCH v3 2/3] QIOChannelSocket: Implement io_async_write & io_async_flush Leonardo Bras
2021-09-24 17:38 ` Daniel P. Berrangé
2021-09-29 19:32 ` Leonardo Bras Soares Passos
2021-09-30 8:39 ` Daniel P. Berrangé
2021-09-28 22:45 ` Peter Xu
2021-09-29 19:36 ` Leonardo Bras Soares Passos
2021-09-29 19:58 ` Peter Xu [this message]
2021-09-22 22:24 ` [PATCH v3 3/3] multifd: Send using asynchronous write on nocomp to send RAM pages Leonardo Bras
2021-09-24 17:43 ` Daniel P. Berrangé
2021-09-28 22:48 ` Peter Xu
2021-09-29 19:46 ` Leonardo Bras Soares Passos
2021-09-29 19:44 ` Leonardo Bras Soares Passos
2021-09-28 22:50 ` [PATCH v3 0/3] QIOChannel async_write & async_flush + MSG_ZEROCOPY + multifd Peter Xu
2021-09-29 18:34 ` Leonardo Bras Soares Passos
2021-09-29 19:22 ` Peter Xu
2021-09-29 19:48 ` Leonardo Bras Soares Passos
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=YVTFgJoxbT4cTn4i@t490s \
--to=peterx@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=jasowang@redhat.com \
--cc=leobras@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.