dvd-sector-copy.c (main): Add a flag to track retrying.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 9 Apr 2022 16:30:41 +0000 (17:30 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 9 Apr 2022 16:30:41 +0000 (17:30 +0100)
Previously we'd try to determine whether retry was intended from whether
there are (begin/stop) events in the queue.  This is bad because we
might have tried to read an empty retry file, in which case we'd still
have no events, but the intend would clearly be to do nothing rather
than re-read the entire input disc.

dvd-sector-copy.c

index c48a179..06d3e55 100644 (file)
@@ -903,6 +903,7 @@ int main(int argc, char *argv[])
 #define f_fixup 4u
 #define f_stats 8u
 #define f_checkid 16u
+#define f_retry 32u
 #define f_write 256u
 
   set_prog(argv[0]);
@@ -978,6 +979,7 @@ int main(int argc, char *argv[])
        }
        if (ferror(fp))
          bail_syserr(errno, "failed to read ranges file `%s'", optarg);
+       f |= f_retry;
        break;
       case 'X':
        fp = fopen(optarg, "r");
@@ -1005,7 +1007,7 @@ int main(int argc, char *argv[])
       case 'c': f |= f_continue; break;
       case 'i': f |= f_checkid; break;
       case 'r':
-       start = 0; end = -1;
+       start = 0; end = -1; f |= f_retry;
        if (parse_range(optarg, PRF_HYPHEN, &start, &end))
          bail("bad range `%s'", optarg);
        if (start < end) {
@@ -1063,8 +1065,9 @@ int main(int argc, char *argv[])
     if (off < 0)
       bail_syserr(errno, "failed to seek to end of output file `%s'",
                  outfile);
-    put_event(EV_WRITE, 0, off/SECTORSZ);
-  } else if (!eventq.n && !(f&f_fixup))
+    put_event(EV_WRITE, 0, off/SECTORSZ); f |= f_retry;
+  }
+  if (!(f&(f_retry | f_fixup)))
     put_event(EV_WRITE, 0, 0);
 
   /* It's fast enough just to check everything. */