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 regression in signal unlisten and document current EE behaviour #687

Closed

Commits on Feb 2, 2015

  1. events: remove indeterminancy from event ordering

    The order of the `newListener` and `removeListener` events with respect
    to the actual adding and removing from the underlying listeners array
    should be deterministic. There is no compelling reason for leaving it
    indeterminate. Changing the ordering is likely to result in breaking
    code that was unwittingly relying on the current behaviour, and the
    indeterminancy makes it impossible to use these events to determine when
    the first or last listener is added for an event.
    sam-github committed Feb 2, 2015
    Configuration menu
    Copy the full SHA
    e53bd67 View commit details
    Browse the repository at this point in the history
  2. process: fix regression in unlistening signals

    When the last signal listener is removed, the signal wrap should be
    closed, restoring the default signal handling behaviour. This is done in
    a (patched) process.removeListener(). However, events.removeAllListeners
    has an optimization to avoid calling removeListener() if there are no
    listeners for the 'removeListener' event, introduced in 56668f5. That
    caused the following code to fail to terminate:
    
        process.stdin.resume();
        function listener() {};
        process.on('SIGINT', listener);
        process.removeAllListeners('SIGINT');
        process.kill(process.pid, 'SIGINT')
    
    while the following will terminate:
    
        process.stdin.resume();
        function listener() {};
        process.on('SIGINT', listener);
        process.removeListener('SIGINT', listener);
        process.kill(process.pid, 'SIGINT')
    
    Replace the method patching with use of the 'newListener' and
    'removeListener' events, which will fire no matter which methods are
    used to add or remove listeners.
    sam-github committed Feb 2, 2015
    Configuration menu
    Copy the full SHA
    09653fb View commit details
    Browse the repository at this point in the history