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 ignores sometimes not being applied correctly due to thread-related race conditions #493

Commits on Jan 13, 2021

  1. Fix ignores sometimes not being applied correctly due to thread-relat…

    …ed race conditions
    
    `set_patterns` is called by `ListenerWorkerThread` and modifies variables used by the main wpull thread. This introduces several race conditions. For example, this means that `_compiled` may rarely get cleared during the iteration in `ignores`, and `patterns` might change during compilation.
    
    For performance reasons, it's undesirable to use a lock on every call to `ignores`, especially as that method might get called many millions of times on large jobs. This implements an intermediate solution that avoids such locking. `_compiled` is only changed by the main thread, therefore the actual ignoring can't be affected by the updates. The updater thread might change `_primary` and `patterns` during or after the recompilation condition, however, such a change would always also require a recompilation anyway, and that is guaranteed to happen either during that `ignores` call or on the next one. The same applies if the change occurs after the recompilation. Although it doesn't completely prevent them, this mitigates possible race conditions.
    JustAnotherArchivist committed Jan 13, 2021
    Configuration menu
    Copy the full SHA
    4ce74e6 View commit details
    Browse the repository at this point in the history