aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-02-06 12:30:50 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-02-06 19:35:38 +0100
commitfa49651e05a06512e18ccb2f54a7198c9ff579de (patch)
tree76f9cd0a4fc774ea236d33ec4d8b396b0b85da37 /thread.c
parent28da9909849dc02abe74de8170fe4036534361ba (diff)
downloadruby-fa49651e05a06512e18ccb2f54a7198c9ff579de.tar.gz
Only emit circular dependency warning for owned thread shields
[Bug #19415] If multiple threads attemps to load the same file concurrently it's not a circular dependency issue. So we check that the existing ThreadShield is owner by the current fiber before warning about circular dependencies.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 54055746db..89c5572201 100644
--- a/thread.c
+++ b/thread.c
@@ -4920,6 +4920,17 @@ rb_thread_shield_new(void)
return thread_shield;
}
+bool
+rb_thread_shield_owned(VALUE self)
+{
+ VALUE mutex = GetThreadShieldPtr(self);
+ if (!mutex) return false;
+
+ rb_mutex_t *m = mutex_ptr(mutex);
+
+ return m->fiber == GET_EC()->fiber_ptr;
+}
+
/*
* Wait a thread shield.
*