summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-21 02:04:38 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-21 02:39:34 +0900
commit6be61ab264c98c96e26b5d3398cf80b49197ba29 (patch)
tree8e46dc16ea36e0eb1af885ba72d7f24e75b375c6
parent435b619a3d5a2d5754a3f739c50f64d1ad520ffc (diff)
should use owned_p instead of locked_p
It should raise an error if the same thread tris to call receive/receive_if.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3949
-rw-r--r--common.mk1
-rw-r--r--ractor.c3
2 files changed, 3 insertions, 1 deletions
diff --git a/common.mk b/common.mk
index 607ad861aa..2cfa952131 100644
--- a/common.mk
+++ b/common.mk
@@ -10213,6 +10213,7 @@ ractor.$(OBJEXT): $(top_srcdir)/internal/serial.h
ractor.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
ractor.$(OBJEXT): $(top_srcdir)/internal/string.h
ractor.$(OBJEXT): $(top_srcdir)/internal/struct.h
+ractor.$(OBJEXT): $(top_srcdir)/internal/thread.h
ractor.$(OBJEXT): $(top_srcdir)/internal/vm.h
ractor.$(OBJEXT): $(top_srcdir)/internal/warnings.h
ractor.$(OBJEXT): {$(VPATH)}assert.h
diff --git a/ractor.c b/ractor.c
index be067d6113..7c5c864612 100644
--- a/ractor.c
+++ b/ractor.c
@@ -12,6 +12,7 @@
#include "internal/hash.h"
#include "internal/rational.h"
#include "internal/struct.h"
+#include "internal/thread.h"
#include "variable.h"
#include "gc.h"
#include "transient_heap.h"
@@ -473,7 +474,7 @@ ractor_basket_accept(struct rb_ractor_basket *b)
static void
ractor_recursive_receive_if(rb_ractor_t *r)
{
- if (r->receiving_mutex && rb_mutex_locked_p(r->receiving_mutex)) {
+ if (r->receiving_mutex && rb_mutex_owned_p(r->receiving_mutex)) {
rb_raise(rb_eRactorError, "can not call receive/receive_if recursively");
}
}