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 race condition starting CacheCleanupThread #586

Merged
merged 1 commit into from
Jun 22, 2023

Commits on Jun 22, 2023

  1. Fix race condition starting CacheCleanupThread

    This fixes two race conditions
    
    1. Thread execution may start before `CacheCleanupThread.new` returns the class instance. In this case `t` is not yet defined inside the thread block and results in a "undefined method `sleepy_run' for nil:NilClass" error.
    
    2. Thread execution may start before member variables `@store`, `@interval`, etc are initialized in `CacheCleanupThread#initialize` This results in "undefined method '*' for nil:NilClass" in should_cleanup? (this error only occurs after the first race condition is fixed)
    
    More detail: A subclassed thread is scheduled for execution as soon as `super` is called. The code block of the thread may start to execute before the class is fully instantiated. See https://www.ruby-forum.com/t/thread-super-should-be-first-line-or-last-line/150617
    willkoehler committed Jun 22, 2023
    Configuration menu
    Copy the full SHA
    0f6aeb9 View commit details
    Browse the repository at this point in the history