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

[libvirt] [PATCH v2 5/5] add pthread_cancel() support



---
 src/util/threads-pthread.c |    9 +++++++++
 src/util/threads.h         |    2 ++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 82ce5c6..791c5a5 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -253,3 +253,12 @@ void virThreadLocalSet(virThreadLocalPtr l, void *val)
 {
     pthread_setspecific(l->key, val);
 }
+
+int virThreadCancel(virThreadPtr thread)
+{
+    int ret;
+    if ((ret = pthread_cancel(thread->thread)) != 0){
+        return -1;
+    }
+    return 0;
+}
diff --git a/src/util/threads.h b/src/util/threads.h
index b72610c..dd456b5 100644
--- a/src/util/threads.h
+++ b/src/util/threads.h
@@ -45,6 +45,7 @@ int virThreadInitialize(void) ATTRIBUTE_RETURN_CHECK;
 void virThreadOnExit(void);
 
 typedef void (*virThreadFunc)(void *opaque);
+typedef void (*virThreadCleanupFunc)(void *opaque);
 
 int virThreadCreate(virThreadPtr thread,
                     bool joinable,
@@ -99,6 +100,7 @@ int virThreadLocalInit(virThreadLocalPtr l,
                        virThreadLocalCleanup c) ATTRIBUTE_RETURN_CHECK;
 void *virThreadLocalGet(virThreadLocalPtr l);
 void virThreadLocalSet(virThreadLocalPtr l, void*);
+int virThreadCancel(virThreadPtr thread);
 
 # ifdef WIN32
 #  include "threads-win32.h"
-- 
1.7.1


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