diff mbox series

[ovs-dev,v1,6/8] ovs-thread: Quiesce when joining pthreads

Message ID bfcc6924e12faf7918800e36615868c6a3b7e88d.1619564350.git.grive@u256.net
State Superseded
Headers show
Series RCU: Add blocking mode for debugging | expand

Commit Message

Gaetan Rivet April 27, 2021, 11:03 p.m. UTC
Joining pthreads makes the caller quiescent. It should register as such,
as joined threads may wait on an RCU callback executing before quitting,
deadlocking the caller.

Signed-off-by: Gaetan Rivet <grive@u256.net>
---
 lib/ovs-thread.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index 805cba622..bf58923f8 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -180,8 +180,6 @@  XPTHREAD_FUNC1(pthread_cond_destroy, pthread_cond_t *);
 XPTHREAD_FUNC1(pthread_cond_signal, pthread_cond_t *);
 XPTHREAD_FUNC1(pthread_cond_broadcast, pthread_cond_t *);
 
-XPTHREAD_FUNC2(pthread_join, pthread_t, void **);
-
 typedef void destructor_func(void *);
 XPTHREAD_FUNC2(pthread_key_create, pthread_key_t *, destructor_func *);
 XPTHREAD_FUNC1(pthread_key_delete, pthread_key_t);
@@ -191,6 +189,20 @@  XPTHREAD_FUNC2(pthread_setspecific, pthread_key_t, const void *);
 XPTHREAD_FUNC3(pthread_sigmask, int, const sigset_t *, sigset_t *);
 #endif
 
+void
+xpthread_join(pthread_t thread, void **retval)
+{
+    int error;
+
+    ovsrcu_quiesce_start();
+    error = pthread_join(thread, retval);
+    ovsrcu_quiesce_end();
+
+    if (OVS_UNLIKELY(error)) {
+        ovs_abort(error, "%s failed", __func__);
+    }
+}
+
 static void
 ovs_mutex_init__(const struct ovs_mutex *l_, int type)
 {