diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-04-07 09:22:30 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2010-04-07 09:22:30 +0200 |
commit | 1c8dc990dc20efbd6cd8e56a57c0fa567c2d6fc8 (patch) | |
tree | 707a3001b6e60e8cc67f7d58804854d96ecdd4f3 /extras/scsi_id/scsi_serial.c | |
parent | 09a5b335b5505adb4bbc79802ceee3b1816864e8 (diff) |
scsi_id: add rand() in retry loop
Diffstat (limited to 'extras/scsi_id/scsi_serial.c')
-rw-r--r-- | extras/scsi_id/scsi_serial.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c index 0c9d9c3095..8752e14971 100644 --- a/extras/scsi_id/scsi_serial.c +++ b/extras/scsi_id/scsi_serial.c @@ -863,21 +863,21 @@ int scsi_get_serial(struct udev *udev, { unsigned char page0[SCSI_INQ_BUFF_LEN]; int fd = -1; - int cnt = 10; + int cnt; int ind; int retval; memset(dev_scsi->serial, 0, len); dbg(udev, "opening %s\n", devname); - while (--cnt) { - const struct timespec duration = { 0, 500 * 1000 * 1000 }; + srand((unsigned int)getpid()); + for (cnt = 20; cnt > 0; cnt--) { + struct timespec duration; fd = open(devname, O_RDONLY | O_NONBLOCK); - if (fd >= 0) - break; - info(udev, "%s: cannot open %s: %s\n", dev_scsi->kernel, devname, strerror(errno)); - if (errno != EBUSY) + if (fd >= 0 || errno != EBUSY) break; + duration.tv_sec = 0; + duration.tv_nsec = (200 * 1000 * 1000) + (rand() % 100 * 1000 * 1000); nanosleep(&duration, NULL); } if (fd < 0) |