From a2997142952942fe0ca1c4db63bfb8a60c413191 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 23 Jan 2012 14:58:13 +0000 Subject: [PATCH] Add API for thread cancellation Add a virThreadCancel function. This functional is 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 --- src/libvirt_private.syms | 1 + src/util/virthread.h | 4 ++++ src/util/virthreadpthread.c | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 599b71edd3..8fe0b97a4f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1744,6 +1744,7 @@ virMutexInitRecursive; virMutexLock; virMutexUnlock; virOnce; +virThreadCancel; virThreadCreate; virThreadID; virThreadInitialize; diff --git a/src/util/virthread.h b/src/util/virthread.h index c59a2cfddf..ca1306a8ab 100644 --- a/src/util/virthread.h +++ b/src/util/virthread.h @@ -55,6 +55,10 @@ void virThreadSelf(virThreadPtr thread); bool virThreadIsSelf(virThreadPtr thread); void virThreadJoin(virThreadPtr thread); +/* This API is *NOT* for general use. It exists solely as a stub + * for integration with libselinux AVC callbacks */ +void virThreadCancel(virThreadPtr thread); + /* These next two functions are for debugging only, since they are not * guaranteed to give unique values for distinct threads on all * architectures, nor are the two functions guaranteed to give the same diff --git a/src/util/virthreadpthread.c b/src/util/virthreadpthread.c index 9f02ba1b04..b42b333853 100644 --- a/src/util/virthreadpthread.c +++ b/src/util/virthreadpthread.c @@ -236,6 +236,11 @@ void virThreadJoin(virThreadPtr thread) pthread_join(thread->thread, NULL); } +void virThreadCancel(virThreadPtr thread) +{ + pthread_cancel(thread->thread); +} + int virThreadLocalInit(virThreadLocalPtr l, virThreadLocalCleanup c) {