
On 07/18/2011 05:13 AM, Guannan Ren wrote:
Independantly of this, IMHO pthread cancellation handlers are a recipe for trouble because it is incredibly hard to make sure you correctly cleanup all resources in the thread, even with use of cleanup handlers.
IMHO, threads should be made to monitor some external "quit" boolean variable (eg see threadpool.c thread termination).
Daniel yep but the push and pop function couldn't be in different function, according to man page as follows.
The concept of pushing and popping handlers isn't the bottleneck here, rather, it is that _all_ functions in the callstack must reliably use the push/pop handlers correctly, before _any_ function can call pthread_cancel on the entire callstack. Right now, none of our code uses any push/pop handlers. Therefore, it becomes a much larger patch to properly insert push/pop handlers into the entire call chain than it is to just write the worker thread to periodically check if any other thread has requested an early quit. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org