aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorJean byroot Boussier <jean.boussier+github@shopify.com>2023-02-06 23:30:42 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-02-08 09:50:00 +0100
commit8ce2fb9bbbaea14737c84385b1573f743a30f773 (patch)
treeb1909a3f62f01b61b19369028c698bc7fbc8692e /thread.c
parent3ab34551450c7a3a3e1ae0b24bf6b78d26129dfa (diff)
downloadruby-8ce2fb9bbbaea14737c84385b1573f743a30f773.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.
*