[libvirt] [PATCH 1/8] Add API for thread cancellation

Eric Blake eblake at redhat.com
Fri Mar 8 00:10:36 UTC 2013


On 03/06/2013 05:49 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Add a virThreadCancel function. This functional is inherantly

s/inherantly/inherently/

> dangerous and not something we want to use in general, but
> integration with SELinux requires that we provide this stub.
> We leave out any Win32 impl to discourage further use and
> because obviously SELinux isn't enabled on Win32
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  src/libvirt_private.syms    | 1 +
>  src/util/virthread.h        | 1 +
>  src/util/virthreadpthread.c | 5 +++++
>  3 files changed, 7 insertions(+)
> 

> +++ b/src/util/virthreadpthread.c
> @@ -236,6 +236,11 @@ void virThreadJoin(virThreadPtr thread)
>      pthread_join(thread->thread, NULL);
>  }
>  
> +void virThreadCancel(virThreadPtr thread)

It would help to add documentation right before this implementation that
mentions that the function exists SOLELY for use by threads created by
third-party libraries which are prepared for cancellation, and that most
libvirt threads do not qualify.  Having the discouraging comment tucked
away solely in the commit message won't help a future coder who doesn't
realize the dangers.

ACK with the comment added.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130307/d81d27e9/attachment-0001.sig>


More information about the libvir-list mailing list