Retrying 3 times on EBUSY drives with generous usleep intervals

This commit is contained in:
Thomas Schmitt 2009-06-14 09:49:47 +00:00
parent 4c920b50e2
commit b7bb047464
2 changed files with 16 additions and 4 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2009.06.03.185118"
#define Cdrskin_timestamP "2009.06.14.095004"

View File

@ -470,7 +470,7 @@ static int sg_fcntl_lock(int *fd, char *fd_name, int l_type, int verbous)
/* ts A60926 */
static int sg_open_drive_fd(char *fname, int scan_mode)
{
int open_mode = O_RDWR, fd;
int open_mode = O_RDWR, fd, tries= 0;
char msg[81];
/* ts A70409 : DDLP-B */
@ -503,6 +503,7 @@ static int sg_open_drive_fd(char *fname, int scan_mode)
!!(open_mode&O_EXCL),!!(open_mode&O_NDELAY));
*/
try_open:;
fd = open(fname, open_mode);
if (fd == -1) {
/* <<< debugging
@ -511,6 +512,17 @@ static int sg_open_drive_fd(char *fname, int scan_mode)
fname,errno);
*/
if (errno == EBUSY) {
tries++;
/* <<< debugging
fprintf(stderr,
"\nlibburn_DEBUG: EBUSY , tries= %d\n", tries);
*/
if (tries < 4) {
usleep(2000000);
goto try_open;
}
sg_handle_busy_device(fname, errno);
return -1;