sqreen-alt 1.10.2 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16186d53b0984c0463633198bf2210cfbe064824f53f30cedfda19c240c41a49
4
- data.tar.gz: 73590a2c4f70f9fa70ed6755c2d9ac6e84cff95ed218143b12cf260d83f8ed63
3
+ metadata.gz: 4a169f32476ad6277d799d9bd4d0863af3773a11ed06c333c730de94b2ac22ca
4
+ data.tar.gz: 45f88106b370b133a77a170d5a35aab1e256a1802f7e520464cc8743f15fe1d3
5
5
  SHA512:
6
- metadata.gz: 5ebd96ffdc51c557831d7b75fa42112e7f24259f64847177c7df263c7395accac3936f84c56cdf99298ba970b7bc2eefe096bf3fd604840480f2915b85b05dbd
7
- data.tar.gz: 1aebe82d2440739f96029c67c6731f301dd83a15eda8d40a27316c374565df3ad8635f328e31a7bb8d085f7c0c8c10956a84be050cb8eec4f0716f0edd8c606f
6
+ metadata.gz: cc167b552a154fd6776b8ed4eab9084e6679812df4c0efef3dafa753d4af5b605dba73839773b35f08b95d291d82e71e3bc74ec33e58acb56baee480d2ccb845
7
+ data.tar.gz: df8d0458e197eb4fcebf909f0cf3ce3b7cd1067b45d14503b67f87c4f422e8c0b1692ab3e10b55278ffdffa828dbe04f2f12095f562e6bba9c831912895a6d4e
@@ -147,23 +147,35 @@ module Sqreen
147
147
  end
148
148
  end
149
149
 
150
+ def push_runtime(runtime)
151
+ @runtimes.delete_if do |th, _runt|
152
+ th.nil? || !th.weakref_alive? || !th.alive?
153
+ end
154
+ @runtimes.push [WeakRef.new(Thread.current), runtime, Thread.current.object_id]
155
+ end
156
+
157
+ def dispose_runtime(runtime)
158
+ @runtimes.delete_if { |_th, _runt, thid| thid == Thread.current.object_id }
159
+ runtime.dispose
160
+ end
161
+
150
162
  def call_callback(name, inst, args, rv = nil)
151
163
  if SQREEN_MINI_RACER
152
- mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"]
164
+ mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{object_id}"]
153
165
  if mini_racer_context.nil? || mini_racer_context[:r].nil? || !mini_racer_context[:r].weakref_alive?
154
- runtime = MiniRacer::Context.new(snapshot: @snapshot)
155
- @runtimes.push runtime
156
- Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"] = {:c => 0, :r => WeakRef.new(runtime)}
166
+ new_runtime = MiniRacer::Context.new(:snapshot => @snapshot)
167
+ push_runtime new_runtime
168
+ Thread.current["SQREEN_MINI_RACER_CONTEXT_#{object_id}"] = {
169
+ :c => 0,
170
+ :r => WeakRef.new(new_runtime),
171
+ }
157
172
  elsif mini_racer_context[:c] >= GC_MINI_RACER
158
- @runtimes.delete(mini_racer_context[:r])
159
- mini_racer_context[:r].dispose
160
-
161
- new_runtime = MiniRacer::Context.new(snapshot: @snapshot)
162
- @runtimes.push new_runtime
163
-
164
- Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"] = {
173
+ dispose_runtime(mini_racer_context[:r])
174
+ new_runtime = MiniRacer::Context.new(:snapshot => @snapshot)
175
+ push_runtime new_runtime
176
+ Thread.current["SQREEN_MINI_RACER_CONTEXT_#{object_id}"] = {
165
177
  :c => 0,
166
- :r => WeakRef.new(new_runtime)
178
+ :r => WeakRef.new(new_runtime),
167
179
  }
168
180
  end
169
181
  end
@@ -177,7 +189,7 @@ module Sqreen
177
189
  arguments = restrict(name, arguments) if @conditions.key?(name)
178
190
  Sqreen.log.debug { [name, arguments].inspect }
179
191
  if SQREEN_MINI_RACER
180
- mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{self.object_id}"]
192
+ mini_racer_context = Thread.current["SQREEN_MINI_RACER_CONTEXT_#{object_id}"]
181
193
  mini_racer_context[:c] += 1
182
194
  ret = mini_racer_context[:r].eval("#{name}.apply(this, #{::JSON.generate(arguments)})")
183
195
  else
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
2
  # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
3
  module Sqreen
4
- VERSION = '1.10.2'.freeze
4
+ VERSION = '1.10.3'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqreen-alt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen