From fd3f8799005ddb166b651bd9cabf9e5e6323d03a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 4 Mar 2010 12:13:04 +0000 Subject: [PATCH] Showing more patience with temporarily busy drives on Linux --- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/sg-linux.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index 0e67bd36..59f49aac 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2010.03.03.141407" +#define Cdrskin_timestamP "2010.03.04.121441" diff --git a/libburn/trunk/libburn/sg-linux.c b/libburn/trunk/libburn/sg-linux.c index d0d7ee7b..2ef61df1 100644 --- a/libburn/trunk/libburn/sg-linux.c +++ b/libburn/trunk/libburn/sg-linux.c @@ -1651,6 +1651,7 @@ int sg_drive_is_open(struct burn_drive * d) int sg_grab(struct burn_drive *d) { int fd, os_errno= 0, ret; + int max_tries = 3, tries = 0; /* ts A60813 */ int open_mode = O_RDWR; @@ -1684,6 +1685,7 @@ int sg_grab(struct burn_drive *d) value -1 of open(2) war used. */ if(! burn_drive_is_open(d)) { +try_open:; /* ts A60821 <<< debug: for tracing calls which might use open drive fds */ mmc_function_spy(NULL, "sg_grab ----------- opening"); @@ -1717,13 +1719,19 @@ int sg_grab(struct burn_drive *d) fcntl(fd, F_SETOWN, getpid()); d->released = 0; return 1; - } + } else if (errno == EBUSY) + goto drive_is_in_use; libdax_msgs_submit(libdax_messenger, d->global_index, 0x00020003, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, "Could not grab drive", os_errno, 0); return 0; drive_is_in_use:; + tries++; + if (tries < max_tries) { + usleep(2000000); + goto try_open; + } libdax_msgs_submit(libdax_messenger, d->global_index, 0x00020003, LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,