Hi, On Mon, Jul 11 at 05:16, Rich Felker wrote: > In my opinion the patch is unacceptable as-is. Any sleeps need to be > optional and off-by-default, and at least someone should investigate > the time actually needed. Or it could just loop retrying until it's no > longer busy. This would be much more robust.
Here's an alternate along your lines but it's a lot of code for very little gain. I think a static delay is acceptable in a program that is going to be run once in a blue moon. There's still a fixed (is smaller) delay in there, I don't like CPU bound busy loops. With some debug annotation my test rig goes around the loop a maximum of 3 times. So approx 150ms, but I'm guessing this will be very hardware dependent. --- busybox-1.18.3/util-linux/fdisk.c-orig 2011-07-12 10:21:47.000000000 +0100 +++ busybox-1.18.3/util-linux/fdisk.c 2011-07-12 10:26:34.000000000 +0100 @@ -2564,10 +2564,18 @@ printf("Calling ioctl() to re-read partition table\n"); sync(); - /* sleep(2); Huh? */ - i = ioctl_or_perror(dev_fd, BLKRRPART, NULL, - "WARNING: rereading partition table " - "failed, kernel still uses old table"); + for (;;) { + i = ioctl(dev_fd, BLKRRPART, NULL); + if(i == 0) + break; + if(errno != EBUSY) { + bb_perror_msg( + "WARNING: rereading partition table " + "failed, kernel still uses old table"); + break; + } + usleep(50000); + } #if 0 if (dos_changed) printf( -- Bob Dunlop _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox