Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Make polling for tor restart work. Call setupTor only once. #14585

Merged
merged 1 commit into from
Jun 28, 2018

Conversation

riastradh-brave
Copy link
Contributor

@riastradh-brave riastradh-brave commented Jun 27, 2018

Previously, we would never retry polling for tor launch if we ever
made the decision to open a control connection.

  1. If we haven't successfully opened a control connection, make
    sure we call this._polled() on all error paths to process a
    deferred file system watch notification.

  2. If we have opened a control connection enough to set the close
    event handler, call this._polled() to handle a deferred poll
    (which, in the next tick, will either do the work it needs to do,
    or discover that there is already a control connection and do
    nothing).

  3. In the close event handler for the control connection, poll for
    tor launch in case tor relaunched, and all the watch events were
    received and ignored, before we noticed that the control
    connection had closed.

With this, browser-laptop will notice when the tor daemon has come
back after muon executes ses.relaunchTor, without needing to call
setupTor again -- which might have had unpredictable consequences of
multiple simultaneous file system watchers and control connections to
tor.

fix #14584

Auditors: @diracdeltas

Test Plan:

  1. Turn off your network.
  2. Launch Brave.
  3. Open a private tab with Tor enabled.
  4. Check that the console reports tor: daemon listens on ....
  5. Wait 20sec for the connection error dialogue box to pop up.
  6. Hit 'retry connection'.
  7. Check that the console reports tor: daemon listens on ... again.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

Previously, we would never retry polling for tor launch if we ever
made the decision to open a control connection.

1. If we _haven't_ successfully opened a control connection, make
   sure we call this._polled() on all error paths to process a
   deferred file system watch notification.

2. If we have opened a control connection enough to set the `close`
   event handler, call this._polled() to handle a deferred poll
   (which, in the next tick, will either do the work it needs to do,
   or discover that there is already a control connection and do
   nothing).

3. In the `close` event handler for the control connection, poll for
   tor launch in case tor relaunched, and all the watch events were
   received and ignored, before we noticed that the control
   connection had closed.

With this, browser-laptop will notice when the tor daemon has come
back after muon executes ses.relaunchTor, without needing to call
setupTor again -- which might have had unpredictable consequences of
multiple simultaneous file system watchers and control connections to
tor.

fix #14584

Auditors: @diracdeltas

Test Plan:
1. Turn off your network.
2. Launch Brave.
3. Open a private tab with Tor enabled.
4. Check that the console reports `tor: daemon listens on ...`.
5. Wait 20sec for the connection error dialogue box to pop up.
6. Hit 'retry connection'.
7. Check that the console reports `tor: daemon listens on ...` _again_.
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diracdeltas approves of this request 😄👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants