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

Projects
None yet
2 participants
@jochemsiegel
Contributor

jochemsiegel commented May 3, 2012

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.

Fix to prevent eventmachine from stopping when a raise is done in an …
…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

Merge pull request #327 from jochemsiegel/master
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 referenced this pull request Mar 21, 2016

Closed

Segmentation fault #670

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 must not raise exceptions
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 #327 was merged.

@sodabrew sodabrew referenced this pull request Apr 28, 2018

Merged

Fix unbind exceptions #835

sodabrew added a commit to sodabrew/eventmachine that referenced this pull request Apr 28, 2018

The unbind callback must not raise exceptions
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 #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 must not raise exceptions
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 #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 must not raise exceptions
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 #327 was merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment