aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Platt <dplatt@radagast.org>2016-12-15 23:12:07 -0800
committerDave Platt <dplatt@radagast.org>2016-12-15 23:12:07 -0800
commit755e829caa23b9781863e4b1e1d24c3cfee9e8bf (patch)
tree53f5c3ceb611cff495e182f0cf5c08735822c482
parent28963459a4ac43100b8e377d65332d81a2660c0d (diff)
avision.c: abort "wait for light" loop if interrupted
Adds a "cancelled" flag to the Avision device structure, cleared in sane_start() and set in sane_cancel(). Test this flag in wait_4_light() and bail out of the 90-second "wait for the light to warm up" loop if the scan is cancelled.
-rw-r--r--backend/avision.c9
-rw-r--r--backend/avision.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/backend/avision.c b/backend/avision.c
index 945092e..61491a2 100644
--- a/backend/avision.c
+++ b/backend/avision.c
@@ -2756,6 +2756,11 @@ wait_4_light (Avision_Scanner* s)
set_triple (rcmd.transferlen, size);
for (try = 0; try < 90; ++ try) {
+
+ if (s->cancelled) {
+ DBG (3, "wait_4_light: cancelled\n");
+ return SANE_STATUS_CANCELLED;
+ }
DBG (5, "wait_4_light: read bytes %lu\n", (u_long) size);
status = avision_cmd (&s->av_con, &rcmd, sizeof (rcmd), 0, 0, &result, &size);
@@ -6217,6 +6222,7 @@ do_cancel (Avision_Scanner* s)
s->prepared = s->scanning = SANE_FALSE;
s->duplex_rear_valid = SANE_FALSE;
s->page = 0;
+ s->cancelled = 1;
if (sanei_thread_is_valid (s->reader_pid)) {
int exit_status;
@@ -8320,6 +8326,9 @@ sane_start (SANE_Handle handle)
/* Make sure there is no scan running!!! */
if (s->scanning)
return SANE_STATUS_DEVICE_BUSY;
+
+ /* Clear cancellation status */
+ s->cancelled = 0;
/* Make sure we have a current parameter set. Some of the
parameters will be overwritten below, but that's OK. */
diff --git a/backend/avision.h b/backend/avision.h
index 2122e09..b26907f 100644
--- a/backend/avision.h
+++ b/backend/avision.h
@@ -444,6 +444,7 @@ typedef struct Avision_Scanner
SANE_Bool prepared; /* first page marker */
SANE_Bool scanning; /* scan in progress */
unsigned int page; /* page counter, 0: uninitialized, 1: scanning 1st page, ... */
+ int cancelled;
SANE_Parameters params; /* scan window */
Avision_Dimensions avdimen; /* scan window - detailed internals */