break out of sane_start wait loop in case of cancellation

merge-requests/1/head
Jon Chambers 2006-06-14 21:02:59 +00:00
rodzic f61d6d2b80
commit 5346dc4f04
1 zmienionych plików z 18 dodań i 1 usunięć

Wyświetl plik

@ -112,6 +112,7 @@ struct ScannerState
int m_numPages; /* number of complete pages (host byte order) */ int m_numPages; /* number of complete pages (host byte order) */
struct ComBuf m_pageInfo; /* "array" of numPages PageInfo structs */ struct ComBuf m_pageInfo; /* "array" of numPages PageInfo structs */
int m_bFinish; /* set non-0 to signal that we are finished */ int m_bFinish; /* set non-0 to signal that we are finished */
int m_bCancelled; /* set non-0 that bFinish state arose from cancelation */
char m_regName[REG_NAME_SIZE]; /* name with which to register */ char m_regName[REG_NAME_SIZE]; /* name with which to register */
unsigned short m_xres; /* x resolution (network byte order) */ unsigned short m_xres; /* x resolution (network byte order) */
unsigned short m_yres; /* y resolution (network byte order) */ unsigned short m_yres; /* y resolution (network byte order) */
@ -686,6 +687,8 @@ sane_start (SANE_Handle handle)
selTimeVal.tv_sec = 1; selTimeVal.tv_sec = 1;
selTimeVal.tv_usec = 0; selTimeVal.tv_usec = 0;
DBG (5, "sane_start: waiting for scan signal\n"); DBG (5, "sane_start: waiting for scan signal\n");
/* wait again if nothing received */ /* wait again if nothing received */
@ -713,11 +716,18 @@ sane_start (SANE_Handle handle)
} /* while */ } /* while */
/* check whether we were cancelled */
if ( gOpenScanners[iHandle]->m_bCancelled ) status = SANE_STATUS_CANCELLED;
cleanup: cleanup:
FreeComBuf (&buf); FreeComBuf (&buf);
return status; return status;
} /* sane_start */ } /* sane_start */
@ -801,7 +811,14 @@ sane_read (SANE_Handle handle, SANE_Byte * data,
void void
sane_cancel (SANE_Handle handle) sane_cancel (SANE_Handle handle)
{ {
DBG( 5, "sane_cancel: %x\n", (int)handle ); int iHandle = (int) handle;
DBG( 5, "sane_cancel: %x\n", iHandle );
/* signal that bad things are afoot */
gOpenScanners[iHandle]->m_bFinish = 1;
gOpenScanners[iHandle]->m_bCancelled = 1;
} /* sane_cancel */ } /* sane_cancel */
/***********************************************************/ /***********************************************************/