qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] restart a coroutine?


From: Paolo Bonzini
Subject: Re: [Qemu-devel] restart a coroutine?
Date: Mon, 05 Mar 2012 09:07:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]