mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
DEV: bind for thread local vars should yield block
followup on #015051ec without this improvement monkey patch does not work. bind should yield the block it is passed for it to work.
This commit is contained in:
parent
015051ecaf
commit
082f59842d
@ -4,7 +4,9 @@
|
||||
#
|
||||
# Without this patch each time we close a DB connection we spin a thread
|
||||
|
||||
class ::ActiveRecord::ConnectionAdapters::AbstractAdapter
|
||||
module ::ActiveRecord
|
||||
module ConnectionAdapters
|
||||
class AbstractAdapter
|
||||
class StaticThreadLocalVar
|
||||
attr_reader :value
|
||||
|
||||
@ -14,6 +16,9 @@ class ::ActiveRecord::ConnectionAdapters::AbstractAdapter
|
||||
|
||||
def bind(value)
|
||||
raise "attempting to change immutable local var" if value != @value
|
||||
if block_given?
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -39,6 +44,7 @@ class ::ActiveRecord::ConnectionAdapters::AbstractAdapter
|
||||
@prepared_statement_status = Concurrent::ThreadLocalVar.new(true)
|
||||
@visitor.extend(DetermineIfPreparableVisitor)
|
||||
else
|
||||
#@prepared_statement_status = Concurrent::ThreadLocalVar.new(false)
|
||||
@prepared_statement_status = StaticThreadLocalVar.new(false)
|
||||
end
|
||||
|
||||
@ -46,5 +52,6 @@ class ::ActiveRecord::ConnectionAdapters::AbstractAdapter
|
||||
config.fetch(:advisory_locks, true)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user