From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4Sxs-0004T8-Ru for qemu-devel@nongnu.org; Mon, 05 Mar 2012 03:08:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4Sxm-00019P-KC for qemu-devel@nongnu.org; Mon, 05 Mar 2012 03:08:16 -0500 Received: from plane.gmane.org ([80.91.229.3]:57663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4Sxm-00019K-Cw for qemu-devel@nongnu.org; Mon, 05 Mar 2012 03:08:10 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1S4Sxj-0008Tf-VD for qemu-devel@nongnu.org; Mon, 05 Mar 2012 09:08:07 +0100 Received: from 93-34-182-16.ip50.fastwebnet.it ([93.34.182.16]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 05 Mar 2012 09:08:07 +0100 Received: from pbonzini by 93-34-182-16.ip50.fastwebnet.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 05 Mar 2012 09:08:07 +0100 From: Paolo Bonzini Date: Mon, 05 Mar 2012 09:07:57 +0100 Message-ID: References: <4F536316.5050503@msgid.tls.msk.ru> <4F53938D.3050004@redhat.com> <4F53CA06.2030600@msgid.tls.msk.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit In-Reply-To: <4F53CA06.2030600@msgid.tls.msk.ru> Subject: Re: [Qemu-devel] restart a coroutine? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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