Eric Blake <eblake(a)redhat.com> wrote on 03/22/2012 03:54:31 PM:
pthread_cancel() tends to imply that you are properly managing signal
blocking across threads; we haven't used it anywhere else in libvirt,
and I'm extremely wary of pulling it in now, as there's probably a lot
of subtle bugs that it would expose. Are you sure you can't do this in
some other manner without dragging in pthread_cancel()?
Well, I was trying to avoid it in the earlier versions, but we ran
into races where a new snooper thread could start up on the same interface
before the old one woke up and noticed it was supposed to die; the old
thread would then interfere with the new thread in unpleasant ways.
I certainly had no problems with it during my testing. In this case,
an asynchronous signal to kill an otherwise blocked-on-a-read thread
is exactly what we need.
That said, I think it's possible to avoid it, but using it greatly
simplified the restart and reload cases. If you think it's too much
risk, I can take a shot at reworking that to avoid it again.
+-DLS