[PATCH 1/8] Add API for thread cancellation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Add a virThreadCancel function. This functional is inherantly
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@xxxxxxxxxx>
---
 src/libvirt_private.syms    | 1 +
 src/util/virthread.h        | 1 +
 src/util/virthreadpthread.c | 5 +++++
 3 files changed, 7 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ed46479..acaa4d7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1743,6 +1743,7 @@ virMutexInitRecursive;
 virMutexLock;
 virMutexUnlock;
 virOnce;
+virThreadCancel;
 virThreadCreate;
 virThreadID;
 virThreadInitialize;
diff --git a/src/util/virthread.h b/src/util/virthread.h
index c59a2cf..3b11dca 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -54,6 +54,7 @@ int virThreadCreate(virThreadPtr thread,
 void virThreadSelf(virThreadPtr thread);
 bool virThreadIsSelf(virThreadPtr thread);
 void virThreadJoin(virThreadPtr thread);
+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
diff --git a/src/util/virthreadpthread.c b/src/util/virthreadpthread.c
index 9f02ba1..b42b333 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)
 {
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]