Sha256: d4316eb8b03f2680331bc113cbeb0045e2f4c821e9587e728bd7b05a6f00bc1c

Contents?: true

Size: 1.01 KB

Versions: 25

Compression:

Stored size: 1.01 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

# ensure that we're being loaded with an agent
# NOTE: THIS CLASS WILL NOT BE RELOADED B/C WE CANNOT RELOAD THE STANDARD
# thread file

# Request context is still tracked per-thread.  There isn't anything
# particularly order-dependent or stateful about request contexts.  It
# exists mostly for reference.
#
# Scope HAS to exist per-fiber.

# Monkey-patching Thread#initialize.
class Thread
  alias_method :cs__initialize, :initialize

  def initialize *args, &block
    # Thread.current still references the original(callee) thread that is
    # instantiating this new fiber during initialization
    Contrast::Components::Scope::MONITOR.synchronize do
      if (current_context = Thread.current[:current_context])
        self[:current_context] = current_context.dup
      end

      Contrast::Components::Scope.sweep_dead_ecs
    end

    cs__initialize(*args, &block)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
contrast-agent-4.4.1 lib/contrast/extension/thread.rb
contrast-agent-4.4.0 lib/contrast/extension/thread.rb
contrast-agent-4.3.2 lib/contrast/extension/thread.rb
contrast-agent-4.3.1 lib/contrast/extension/thread.rb
contrast-agent-4.3.0 lib/contrast/extension/thread.rb
contrast-agent-4.2.0 lib/contrast/extension/thread.rb
contrast-agent-4.1.0 lib/contrast/extension/thread.rb
contrast-agent-4.0.0 lib/contrast/extension/thread.rb
contrast-agent-3.16.0 lib/contrast/extension/thread.rb
contrast-agent-3.15.0 lib/contrast/extension/thread.rb
contrast-agent-3.14.0 lib/contrast/extension/thread.rb
contrast-agent-3.13.2 lib/contrast/extension/thread.rb
contrast-agent-3.13.1 lib/contrast/extension/thread.rb
contrast-agent-3.13.0 lib/contrast/extension/thread.rb
contrast-agent-3.12.2 lib/contrast/extension/thread.rb
contrast-agent-3.12.1 lib/contrast/extension/thread.rb
contrast-agent-3.12.0 lib/contrast/extension/thread.rb
contrast-agent-3.11.0 lib/contrast/extensions/ruby_core/thread.rb
contrast-agent-3.10.2 lib/contrast/extensions/ruby_core/thread.rb
contrast-agent-3.10.1 lib/contrast/extensions/ruby_core/thread.rb