Skip to content

Commit 39173fe

Browse files
committed
Reject all envelops sent to termiated actor before actor is GCed
1 parent 19466d1 commit 39173fe

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/concurrent/actress.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ def terminate!
205205
guard!
206206
@terminated.set
207207
parent_core.remove_child reference if parent_core
208+
@mailbox.each do |envelope|
209+
reject_envelope envelope
210+
logger.debug "rejected #{envelope.message} from #{envelope.sender_path}"
211+
end
212+
@mailbox.clear
208213
# TODO terminate all children
209214
end
210215

@@ -224,12 +229,6 @@ def process?
224229
def receive_envelope
225230
envelope = @mailbox.shift
226231

227-
if terminated?
228-
# FIXME make sure that it cannot be GCed before all messages are rejected after termination
229-
reject_envelope envelope
230-
logger.debug "rejected #{envelope.message} from #{envelope.sender_path}"
231-
return
232-
end
233232
logger.debug "received #{envelope.message} from #{envelope.sender_path}"
234233

235234
result = @actress.on_envelope envelope

0 commit comments

Comments
 (0)