Skip to content

Commit

Permalink
Fix hang in Channel subscribe/close/drain
Browse files Browse the repository at this point in the history
When we polled a Channel, we forgot to re-insert the CLOSE or FAIL
message. This meant that under certain use patterns, such as when we
had a subscription to a Channel, closed it, and then tried to drain it
with a `for` loop, we could get a hang, since the draining loop never
saw the CLOSE message.
  • Loading branch information
jnthn committed Jan 14, 2019
1 parent 5fcba5b commit 9b77459
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/Channel.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ my class Channel does Awaitable {
nqp::istype(msg, CHANNEL_CLOSE),
nqp::stmts(
$!closed_promise_vow.keep(Nil),
nqp::push($!queue, msg),
Nil
),
nqp::if(
nqp::istype(msg, CHANNEL_FAIL),
nqp::stmts(
$!closed_promise_vow.break(msg.error),
nqp::push($!queue, msg),
Nil
),
msg
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ S16-io/words.t
S16-unfiled/rebindstdhandles.t
S17-channel/basic.t
S17-channel/stress.t # stress slow
S17-channel/subscription-drain-in-react.t
S17-lowlevel/atomic.t # moar
S17-lowlevel/atomic-ops.t # moar
S17-lowlevel/cas.t
Expand Down

0 comments on commit 9b77459

Please sign in to comment.