method
render_details
v7.1.3.4 -
Show latest stable
-
0 notes -
Class: DebugLocks
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
render_details(req)
private
Hide source
# File actionpack/lib/action_dispatch/middleware/debug_locks.rb, line 47 def render_details(req) threads = ActiveSupport::Dependencies.interlock.raw_state do |raw_threads| # The Interlock itself comes to a complete halt as long as this block # is executing. That gives us a more consistent picture of everything, # but creates a pretty strong Observer Effect. # # Most directly, that means we need to do as little as possible in # this block. More widely, it means this middleware should remain a # strictly diagnostic tool (to be used when something has gone wrong), # and not for any sort of general monitoring. raw_threads.each.with_index do |(thread, info), idx| info[:index] = idx info[:backtrace] = thread.backtrace end raw_threads end str = threads.map do |thread, info| if info[:exclusive] lock_state = +"Exclusive" elsif info[:sharing] > 0 lock_state = +"Sharing" lock_state << " x#{info[:sharing]}" if info[:sharing] > 1 else lock_state = +"No lock" end if info[:waiting] lock_state << " (yielded share)" end msg = +"Thread #{info[:index]} [0x#{thread.__id__.to_s(16)} #{thread.status || 'dead'}] #{lock_state}\n" if info[:sleeper] msg << " Waiting in #{info[:sleeper]}" msg << " to #{info[:purpose].to_s.inspect}" unless info[:purpose].nil? msg << "\n" if info[:compatible] compat = info[:compatible].map { |c| c == false ? "share" : c.to_s.inspect } msg << " may be pre-empted for: #{compat.join(', ')}\n" end blockers = threads.values.select { |binfo| blocked_by?(info, binfo, threads.values) } msg << " blocked by: #{blockers.map { |i| i[:index] }.join(', ')}\n" if blockers.any? end blockees = threads.values.select { |binfo| blocked_by?(binfo, info, threads.values) } msg << " blocking: #{blockees.map { |i| i[:index] }.join(', ')}\n" if blockees.any? msg << "\n#{info[:backtrace].join("\n")}\n" if info[:backtrace] end.join("\n\n---\n\n\n") [200, { Rack::CONTENT_TYPE => "text/plain; charset=#{ActionDispatch::Response.default_charset}", Rack::CONTENT_LENGTH => str.size.to_s }, [str]] end