qemu-devel
[Top][All Lists]
Advanced

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

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


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] Merge NBD client/server int qemu-nbd
Date: Sat, 14 Jun 2008 10:12:31 -0500
User-agent: Thunderbird 2.0.0.14 (X11/20080501)

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 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.

Regards,

Anthony Liguori

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 = 5;
while ((fd = open(device, O_RDWR)) == -1 && timeout--)
    sleep(1);

Any suggestion ???

Regards,
Laurent





reply via email to

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