From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7EBz-0004cA-1j for qemu-devel@nongnu.org; Fri, 13 Jun 2008 14:40:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7EBu-0004Zl-M8 for qemu-devel@nongnu.org; Fri, 13 Jun 2008 14:40:05 -0400 Received: from [199.232.76.173] (port=43183 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7EBu-0004ZJ-1W for qemu-devel@nongnu.org; Fri, 13 Jun 2008 14:40:02 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:55008) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K7EBs-00008P-KV for qemu-devel@nongnu.org; Fri, 13 Jun 2008 14:40:01 -0400 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id D61E519D915 for ; Fri, 13 Jun 2008 20:40:31 +0200 (CEST) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14962-10 for ; Fri, 13 Jun 2008 20:40:28 +0200 (CEST) Received: from cyclope.frec.bull.fr (cyclope.frec.bull.fr [129.183.4.9]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 26D0F19D933 for ; Fri, 13 Jun 2008 20:40:28 +0200 (CEST) Received: from [129.184.32.122] (client32-122.vpn_client.bull.fr [129.184.32.122]) by cyclope.frec.bull.fr (Postfix) with ESMTP id 533C227289 for ; Fri, 13 Jun 2008 20:40:25 +0200 (CEST) Subject: Re: [Qemu-devel] [PATCH] Merge NBD client/server int qemu-nbd From: Laurent Vivier In-Reply-To: <4852B339.5090307@codemonkey.ws> References: <1213370134.4833.29.camel@frecb07144> <4852B339.5090307@codemonkey.ws> Content-Type: text/plain; charset=utf-8 Date: Fri, 13 Jun 2008 20:39:54 +0200 Message-Id: <1213382394.3803.9.camel@frecb07144> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Le vendredi 13 juin 2008 =C3=A0 12:49 -0500, Anthony Liguori a =C3=A9crit= : > Laurent Vivier wrote: [...] > > +static void show_parts(const char *device) > > +{ > > + if (fork() =3D=3D 0) { > > + int nbd; > > + > > + /* wait device */ > > + sleep(1); > > =20 >=20 > This looks like a big red-herring. What is this sleep waiting for any=20 > can it be possibly made into something less racy? Yes, I know, it's BAD (and it can failed sometime...) But show_parts() must wait its parent has entered in nbd_trip() loop. Because the open() calls /dev/nbd0 which calls through the socket its parent and IMHO there is no easy way to know if the server is ready to process the request. Perhaps something like: int timeout =3D 5; while ((fd =3D open(device, O_RDWR)) =3D=3D -1 && timeout--) sleep(1); Any suggestion ??? Regards, Laurent --=20 ------------- Laurent.Vivier@bull.net --------------- "The best way to predict the future is to invent it." - Alan Kay