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