qemu-devel@nongnu.org
[Top] [All Lists]

Re: [Qemu-devel] [PATCH] Merge NBD client/server int qemu-nbd

Subject: Re: [Qemu-devel] [PATCH] Merge NBD client/server int qemu-nbd
From: Laurent Vivier
Date: Sat, 14 Jun 2008 20:47:13 +0200
Le samedi 14 juin 2008 Ã 10:12 -0500, Anthony Liguori a Ãcrit :
> Laurent Vivier wrote:
> > Le vendredi 13 juin 2008 Ã 12:49 -0500, Anthony Liguori a Ãcrit :
> >   
> >> Laurent Vivier wrote:
> >>     
> > [...]
> >   
> >>> +static void show_parts(const char *device)
> >>> +{
> >>> +    if (fork() == 0) {
> >>> +        int nbd;
> >>> +
> >>> + /* wait device */
> >>> +        sleep(1);
> >>>   
> >>>       
> >> This looks like a big red-herring.  What is this sleep waiting for any 
> >> 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.
> >   
> 
> You mean, listen() has to be called on the fd in the server?  You have 
> two choices I think.  You could wait to fork the child until after 
> you've listen()'d which is probably the most elegant solution.  If 

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 
> 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
-- 
------------- Laurent.Vivier@xxxxxxxx ---------------
"The best way to predict the future is to invent it."
- Alan Kay



<Prev in Thread] Current Thread [Next in Thread>