should use owned_p instead of locked_p

It should raise an error if the same thread tris to call
receive/receive_if.
This commit is contained in:
Koichi Sasada 2020-12-21 02:04:38 +09:00
parent 435b619a3d
commit 6be61ab264
Notes: git 2020-12-21 02:39:57 +09:00
2 changed files with 3 additions and 1 deletions

View File

@ -10213,6 +10213,7 @@ ractor.$(OBJEXT): $(top_srcdir)/internal/serial.h
ractor.$(OBJEXT): $(top_srcdir)/internal/static_assert.h ractor.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
ractor.$(OBJEXT): $(top_srcdir)/internal/string.h ractor.$(OBJEXT): $(top_srcdir)/internal/string.h
ractor.$(OBJEXT): $(top_srcdir)/internal/struct.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/vm.h
ractor.$(OBJEXT): $(top_srcdir)/internal/warnings.h ractor.$(OBJEXT): $(top_srcdir)/internal/warnings.h
ractor.$(OBJEXT): {$(VPATH)}assert.h ractor.$(OBJEXT): {$(VPATH)}assert.h

View File

@ -12,6 +12,7 @@
#include "internal/hash.h" #include "internal/hash.h"
#include "internal/rational.h" #include "internal/rational.h"
#include "internal/struct.h" #include "internal/struct.h"
#include "internal/thread.h"
#include "variable.h" #include "variable.h"
#include "gc.h" #include "gc.h"
#include "transient_heap.h" #include "transient_heap.h"
@ -473,7 +474,7 @@ ractor_basket_accept(struct rb_ractor_basket *b)
static void static void
ractor_recursive_receive_if(rb_ractor_t *r) 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"); rb_raise(rb_eRactorError, "can not call receive/receive_if recursively");
} }
} }