summaryrefslogtreecommitdiffstats
path: root/lib/qpthreads.c
diff options
context:
space:
mode:
authorChris Hall (GMCH) <chris.hall@highwayman.com>2009-12-17 17:32:15 +0000
committerChris Hall (GMCH) <chris.hall@highwayman.com>2009-12-17 17:32:15 +0000
commit20d52a027c1fa9072028c73ff08c7c2e1730e844 (patch)
tree41d9fe07176f0e5f24b28c78b9d0fecae81947f3 /lib/qpthreads.c
parentb53c5c3b32a421339bd8414b223d5bfeab950f8b (diff)
downloadquagga-20d52a027c1fa9072028c73ff08c7c2e1730e844.tar.bz2
quagga-20d52a027c1fa9072028c73ff08c7c2e1730e844.tar.xz
Add qpt_thread_join() to lib/qpthreads
Diffstat (limited to 'lib/qpthreads.c')
-rw-r--r--lib/qpthreads.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/qpthreads.c b/lib/qpthreads.c
index e7a8da2f..ba6e20be 100644
--- a/lib/qpthreads.c
+++ b/lib/qpthreads.c
@@ -432,6 +432,34 @@ qpt_thread_create(void* (*start)(void*), void* arg, qpt_thread_attr_t* attr)
return thread_id ;
} ;
+/* Join given thread -- do nothing if !qpthreads_enabled
+ *
+ * Tolerates ESRCH (no thread known by given id).
+ *
+ * Returns whatever the thread returns, NULL otherwise.
+ *
+ * NB: all other errors are FATAL.
+ */
+extern void*
+qpt_thread_join(qpt_thread_t thread_id)
+{
+ int err ;
+ void* ret ;
+
+ if (!qpthreads_enabled)
+ return NULL ;
+
+ err = pthread_join(thread_id, &ret) ;
+
+ if (err == 0)
+ return ret ;
+
+ if (err == ESRCH)
+ return NULL ;
+
+ zabort_err("pthread_join failed", err) ;
+} ;
+
/*==============================================================================
* Mutex initialise and destroy.
*/