Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to prevent event machine from stopping when a raise is done in an unbind. #327

Merged
merged 1 commit into from
Nov 2, 2015

Conversation

jochemsiegel
Copy link
Contributor

Currently, eventmachine will stop when a handler raises an exception in its unbind method. This is an intended feature for when the eventmachine reactor is being stopped, as it is undesirable to keep the reactor running when exceptions are being thrown while connections are being unbound.

This however does cause issues when exceptions are raised in unbinds when eventmachine is not being stopped.

This fix adds a method to the eventmachine cpp module which enables you to check wether or not the reactor is being stopped. Consequently the raising of an exception during an unbind will only resort in a reactor stop if it was already being stopped.

We implemented this locally for a project, tested it and it seems to be working well. Granted, this is only necessary if handler code implements exceptions in the unbind method.

Tests have been added, and the existing ones all still pass.

…unbind.

Eventmachine IS stopped when an exception is raised while eventmachine
is stopping.
@sodabrew sodabrew modified the milestones: v1.0.7, v1.2.0 Feb 4, 2015
sodabrew added a commit that referenced this pull request Nov 2, 2015
Fix to prevent event machine from stopping when a raise is done in an unbind
@sodabrew sodabrew merged commit 3716c8b into eventmachine:master Nov 2, 2015
@emcgee emcgee mentioned this pull request Mar 21, 2016
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 28, 2018
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 28, 2018
The unbind callback absolutely must not raise an exception or the reactor will crash.
If there is no EM.error_handler, or if the error_handler retrows, then stop the reactor,
stash the exception in $wrapped_exception, and the exception will be raised after the
reactor is cleaned up (see the last line of self.run).

This fixes many crash reports in the 1.2 series since eventmachine#327 was merged.
@sodabrew sodabrew mentioned this pull request Apr 28, 2018
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 28, 2018
The unbind callback absolutely must not raise an exception or the reactor will crash.
If there is no EM.error_handler, or if the error_handler retrows, then stop the reactor,
stash the exception in $wrapped_exception, and the exception will be raised after the
reactor is cleaned up (see the last line of self.run).

This fixes many crash reports in the 1.2 series since eventmachine#327 was merged.
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 28, 2018
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 28, 2018
The unbind callback absolutely must not raise an exception or the reactor will crash.
If there is no EM.error_handler, or if the error_handler retrows, then stop the reactor,
stash the exception in $wrapped_exception, and the exception will be raised after the
reactor is cleaned up (see the last line of self.run).

This fixes many crash reports in the 1.2 series since eventmachine#327 was merged.
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 30, 2018
sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 30, 2018
The unbind callback absolutely must not raise an exception or the reactor will crash.
If there is no EM.error_handler, or if the error_handler retrows, then stop the reactor,
stash the exception in $wrapped_exception, and the exception will be raised after the
reactor is cleaned up (see the last line of self.run).

This fixes many crash reports in the 1.2 series since eventmachine#327 was merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants