[sane-devel] pthread_cancel and MacOS X (was: TWAIN SANE Interface for Mac OS X version 0.3)
Sat, 10 Jan 2004 16:09:16 +0100
in the meantime (even Henning urged me to do something with that sanei_thread
stuff ;-) I've included Mattias patch within sanei_thread_kill() and checked
it here on my box with a CanoScan 650.
Result: It will not work - it hangs. Why? Because the plustek backend and
also the plustek_pp and u12 didn't use the pthread_cancel function.
As I do really like the "graceful shutdown" of a process or thread, the
reader_process in the plustek backend terminates, when it has done it's
work. But when using the patch, it is urged to wait on a point where it
does not expect to wait. That's the difference to the test-backend.
The test-backend implements also a "hanging" backend. After it has
done it's work it's sleeping...
When writing the sanei_thread stuff, I expected pthread_cancel to work
correctly, and probably it will work correctly in the near future. I also
think, that pthread_cancel should normally not be needed by any backend
to shutdown a reader-process, when this one is done. It's only needed
to cancel such a thread...
I also think, that a working test-backend is not that essential, as working
So what to do?
I suggest to skip the sanei_thread-patch from Mattias Ellert, as this patch
is not really a workaround for the buggy pthread_cancel on OSX. It only
tries to cure one symptome.
My 2 cents on that,
On Freitag, 9. Januar 2004 09:31, Mattias Ellert wrote:
> Noah Daniels wrote:
> > Hi,
> > I'm still having the same problem with the plustek backend that several
> > people have reported, even using this latest build of the various SANE
> > packages.
> > Basically, sane-find-scanner finds the scanner, but scanimage -L does
> > not. However, if I set SANE_DEBUG_PLUSTEK to a high number, the scanner
> > DOES start working, and scans a partial low-res image before hanging. I
> > know this behavior has been reported before, by Henrik Rintala.
> > I can provide a debug log if anyone's interested... I'd love to be able
> > to get this working (printing to a Canoscan 650).
> > thanks!
> > --
> > Noah Daniels
> Using the latest version of libusb from CVS (or the binary packages from
> 2004-01-05) has been reported to fix the problem that scanimage -L does
> not see the scanner unless the DEBUG environment is used.
> The following gdb log of the state of scanimage at the time it freezes
> after a scan was provided by a user having a Canon N670U scanner that
> uses the Plustek backend on MacOS X.
> To me it looks like the reader process has finished and is waiting to be
> killed, but the main process is still trying to read from it.
> Note that the patch in the bug report
> has been applied here, in order to avoid calling pthread_cancel which is
> broken on MacOS X.