From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] restart a coroutine?
Date: Mon, 05 Mar 2012 09:07:57 +0100 [thread overview]
Message-ID: <jj1s8u$c00$1@dough.gmane.org> (raw)
In-Reply-To: <4F53CA06.2030600@msgid.tls.msk.ru>
Il 04/03/2012 21:01, Michael Tokarev ha scritto:
> This is all fine, except of one thing: restarting (resending) of
> the requests which has been sent to the remote and for which we
> were waiting for reply already.
>
> For these requests, they should be resent using new socket, when
> the connection manager wakes corresponding coroutine up. That's
> where my question comes.
>
> The request handling coroutine looks like regular function
> (pseudocode):
>
> offset = 0;
> while(offset < sendsize) {
> ret = send(sock, senddata+offset, sendsize-offset);
> if (EAGAIN) { coroutine_yeld(); continue; }
> if (ret < 0) return -EIO;
> offset += ret;
> }
> offset = 0;
> while(offset < recvsize) {
> ret = recv(sock, recvdata+offset, recvsize-offset);
> if (EAGAIN) { coroutine_yeld(); continue; }
> if (ret < 0) return -EIO;
> offset += ret;
> }
> return status(recvdata);
>
> This function will need to have a ton of "goto begin" in all places
> where it calls yeld() -- in order to actually start _sending_ the
> request to the new sock after a reconnect.
That's why Avi mentioned (I think) having a list of requests. As soon
as you close the socket, or at least shut it down, all recv and send
will fail and requests will fail. However, if you save the list of
requests before closing, you can restart them on the new socket.
> Is there some mechanism to cancel bdrv_co_{read,write}v()? I see a
> way to cancel bdrv_aio_{read,write}v(), but even these are now
> implemented as coroutines...
Not yet. But I don't think it is necessary.
Paolo
next prev parent reply other threads:[~2012-03-05 8:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-04 12:41 [Qemu-devel] restart a coroutine? Michael Tokarev
2012-03-04 16:08 ` Avi Kivity
2012-03-04 20:01 ` Michael Tokarev
2012-03-05 8:07 ` Paolo Bonzini [this message]
2012-03-05 9:20 ` Avi Kivity
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='jj1s8u$c00$1@dough.gmane.org' \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).