From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7an1-0001li-Ix for qemu-devel@nongnu.org; Sat, 14 Jun 2008 14:47:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7an1-0001lO-2h for qemu-devel@nongnu.org; Sat, 14 Jun 2008 14:47:51 -0400 Received: from [199.232.76.173] (port=60198 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7an0-0001lL-PO for qemu-devel@nongnu.org; Sat, 14 Jun 2008 14:47:50 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:59349) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K7an0-000336-Cm for qemu-devel@nongnu.org; Sat, 14 Jun 2008 14:47:50 -0400 Subject: Re: [Qemu-devel] [PATCH] Merge NBD client/server int qemu-nbd From: Laurent Vivier In-Reply-To: <4853DFDF.7000501@codemonkey.ws> References: <1213370134.4833.29.camel@frecb07144> <4852B339.5090307@codemonkey.ws> <1213382394.3803.9.camel@frecb07144> <4853DFDF.7000501@codemonkey.ws> Content-Type: text/plain; charset=UTF-8 Date: Sat, 14 Jun 2008 20:47:13 +0200 Message-Id: <1213469233.3843.7.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 samedi 14 juin 2008 =C3=A0 10:12 -0500, Anthony Liguori a =C3=A9crit : > Laurent Vivier wrote: > > Le vendredi 13 juin 2008 =C3=A0 12:49 -0500, Anthony Liguori a =C3=A9= crit : > > =20 > >> Laurent Vivier wrote: > >> =20 > > [...] > > =20 > >>> +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 a= ny=20 > >> can it be possibly made into something less racy? > >> =20 > > > > Yes, I know, it's BAD (and it can failed sometime...) > > > > But show_parts() must wait its parent has entered in nbd_trip() loop. > > =20 >=20 > You mean, listen() has to be called on the fd in the server? You have=20 > two choices I think. You could wait to fork the child until after=20 > you've listen()'d which is probably the most elegant solution. If=20 It is already after the listen (even after the accept...). It is why I call show_parts() from the server and not from client. > that's difficult to do, you could have the child inherit one end of a=20 > pipe() and use that in the child to wait for the server to be ready. perhaps I'm wrong, but it seems the server must be waiting on the read() to allow to have a success on the open(), so I don't see how the server can launch show_parts() whereas it is already waiting on the read(). Regards, Laurent --=20 ------------- Laurent.Vivier@bull.net --------------- "The best way to predict the future is to invent it." - Alan Kay