Skip to content

Commit

Permalink
should use owned_p instead of locked_p
Browse files Browse the repository at this point in the history
It should raise an error if the same thread tris to call
receive/receive_if.
  • Loading branch information
ko1 committed Dec 20, 2020
1 parent 435b619 commit 6be61ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions common.mk
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ractor.c
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
}
}
Expand Down

0 comments on commit 6be61ab

Please sign in to comment.