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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure neither sync or queue threads are likely to be mis-managed by accident #1519

Conversation

gonzalo-bulnes
Copy link
Contributor

@gonzalo-bulnes gonzalo-bulnes commented Jun 14, 2022

Description

馃敭 Reviewers rebase this branch once #1518 is merged, only the last three commits need review 馃挌

Future-proves #1518 by ensuring that queue job instances don't ever create QThread instances on the fly, that will be destroyed without the underlying thread being closed. Now that we have convenient tools to manage threads (see below) this should be enough to prevent re-introducing un-managed threads in the future.

from securedrop_client.app import threads

with threads(2) as [my_safer_thread, my_second_safer_thread]:
    pass # or do whatever you want with your two QThread instances

# At this point, the QThread instances will be safely destroyed after the underlying threads are closed.

Test Plan

  • Confirm that the build is green 馃崗
  • Optionally, confirm that the sync happens as usual
  • Optionally, confirm that the messages are downloaded as usual
  • Optionally, confirm that the files can be downloaded as usual

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, the AppArmor profile may need to be updated. Please check as applicable:

  • I have updated the AppArmor profile
  • No update to the AppArmor profile is required for these changes
  • I don't know and would appreciate guidance

If these changes modify the database schema, you should include a database migration. Please check as applicable:

  • I have written a migration and upgraded a test database based on main and confirmed that the migration applies cleanly
  • I have written a migration but have not upgraded a test database based on main and would like the reviewer to do so
  • I need help writing a database migration
  • No database schema changes are needed

@gonzalo-bulnes gonzalo-bulnes marked this pull request as ready for review June 14, 2022 03:51
@gonzalo-bulnes gonzalo-bulnes requested a review from a team as a code owner June 14, 2022 03:51
@gonzalo-bulnes gonzalo-bulnes changed the title Ensure threads are exited before qthread instances are destroyed 3 Ensure neither sync or queue threads are mis-managed by accident Jun 14, 2022
@gonzalo-bulnes gonzalo-bulnes changed the title Ensure neither sync or queue threads are mis-managed by accident Ensure neither sync or queue threads are likely to be mis-managed by accident Jun 14, 2022
@gonzalo-bulnes gonzalo-bulnes force-pushed the ensure-threads-are-exited-before-qthread-instances-are-destroyed-3 branch from 6f14e25 to 7275891 Compare June 22, 2022 01:32
Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

lgtm

@sssoleileraaa sssoleileraaa merged commit 41d5a47 into main Jun 22, 2022
@sssoleileraaa sssoleileraaa deleted the ensure-threads-are-exited-before-qthread-instances-are-destroyed-3 branch June 22, 2022 01:45
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.

None yet

2 participants