Ludovic Rousseau wrote:
> I try to use libusb-0.9.x + libusb-compat with pilot-link 
> (pilot-link is a library used to talk to a Palm PDA).
> I discovered that I have the exact same problem I described in .
> The problem is that pilot-link is creating a thread to manage USB
> communication (function RD_main line 315 of ). When the
> communication is finished this thread is thread_cancel()ed and
> usb_close() is called from the main thread.
My response has not changed from last time either.
Don't use thread_cancel(). It's bad programming practice. For example
you might call thread_cancel() while the thread you are killing has
malloc()ed some memory, causing that memory to never be freed. Implement
a way of signalling your threads to shut down cleanly.
Regardless of my complaints against your pratcitces, I will happily
consider a *clean* way of implementing this but your proposed solution
of using pthread_kill() to check thread existence is not clean. This is
because when threads die holding a mutex, the mutex is still held, and
therefore your patch causes a thread (that doesn't own the mutex) to
unlock it, which the pthread manual explicitly says is illegal.
For now I don't have any other solution or ideas, sorry. But feel free
to suggest other approaches to this.