Skip to content

Commit

Permalink
SQLite::ForkSafety collection is thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Sep 17, 2024
1 parent d16ac2c commit 5428e22
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/sqlite3/fork_safety.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ def _fork
end

@databases = []
@mutex = Mutex.new

class << self
def hook!
::Process.singleton_class.prepend(CoreExt)
end

def track(database)
@databases << WeakRef.new(database)
@mutex.synchronize do
@databases << WeakRef.new(database)
end
end

def discard
Expand Down

0 comments on commit 5428e22

Please sign in to comment.