libuv 2.0.3 → 2.0.4

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
  SHA1:
3
- metadata.gz: c8d3076693c01bb76953ce8b883c5978bb4169a8
4
- data.tar.gz: e5410efdde18367e7b78c3efdcd8f1db8a619e88
3
+ metadata.gz: dc82e51b4569c6be6d73639176fbb4779a5b4d62
4
+ data.tar.gz: 711888d208a4f2719efaa20c52d3815645202ed4
5
5
  SHA512:
6
- metadata.gz: 90c9bee7837dcef7d431ad174f0e096938ec8866261d6fab695146930cbe9e8e503df4ae82ae9e0809c4583cd56cb0dbac8fa36e6565f1edb647820d93028e6d
7
- data.tar.gz: 0efd4cb5ae7ce63058fc76ed1e2a00ce842f2643df776b38a171aa1ecad3cbfefbb3b4bc40c7c1fe68946423065e5e9e0ca58af96b4e7ad91ef045d9040d70f9
6
+ metadata.gz: a6a084029d33260ce7671932c32be0ec450d5c0c9f01e3ea991b2e685b73c89912fe724cec39d4b4e81cd7665eb0d017aab9e3de0c2c547177ab9a23d76e809a
7
+ data.tar.gz: 8a77e498c41b77c819f4eeff6baee7048e053b3ff36a9373f14b7e62c743dba92ccc3d40f609389e1cb8ee8d0a1ecd6e7e004b5ee7a4eb18a779f44e3cba290a
@@ -15,7 +15,7 @@ module Libuv
15
15
  end
16
16
 
17
17
  def define_callback(function:, params: [:pointer], ret_val: :void, lookup: :default_lookup)
18
- @callback_funcs[function] = FFI::Function.new(ret_val, params) do |*args|
18
+ @callback_funcs[function] = ::FFI::Function.new(ret_val, params) do |*args|
19
19
  dispatch_callback(function, lookup, args)
20
20
  end
21
21
  end
@@ -41,8 +41,8 @@ module Libuv
41
41
 
42
42
  def self.included(base)
43
43
  base.instance_variable_set(:@callback_funcs, {})
44
- base.instance_variable_set(:@callback_lookup, ThreadSafe::Cache.new)
45
- base.instance_variable_set(:@callback_lock, Mutex.new)
44
+ base.instance_variable_set(:@callback_lookup, ::ThreadSafe::Cache.new)
45
+ base.instance_variable_set(:@callback_lock, ::Mutex.new)
46
46
  base.extend(ClassMethods)
47
47
  end
48
48
 
@@ -70,7 +70,7 @@ module Libuv
70
70
  assert_type(String, data, WRITE_ERROR)
71
71
 
72
72
  buffer1 = ::FFI::MemoryPointer.from_string(data)
73
- buffer = ::Libuv::Ext.buf_init(buffer1, data.respond_to?(:bytesize) ? data.bytesize : data.size)
73
+ buffer = ::Libuv::Ext.buf_init(buffer1, data.bytesize)
74
74
 
75
75
  # local as this variable will be available until the handle is closed
76
76
  @write_callbacks ||= {}
@@ -174,6 +174,7 @@ module Libuv
174
174
  end
175
175
 
176
176
  def on_shutdown(req, status)
177
+ cleanup_callbacks(req.address)
177
178
  ::Libuv::Ext.free(req)
178
179
  @close_error = check_result(status)
179
180
  close
@@ -156,11 +156,11 @@ module Libuv
156
156
 
157
157
 
158
158
  def pending
159
- @defer.instance_eval { @pending }
159
+ @defer.pending
160
160
  end
161
161
 
162
162
  def value
163
- @defer.instance_eval { @value }
163
+ @defer.value
164
164
  end
165
165
  end
166
166
 
@@ -226,6 +226,8 @@ module Libuv
226
226
  @value = nil
227
227
  @loop = loop
228
228
  end
229
+
230
+ attr_reader :pending, :value
229
231
 
230
232
  #
231
233
  # resolves the derived promise with the value. If the value is a rejection constructed via
@@ -1,3 +1,3 @@
1
1
  module Libuv
2
- VERSION = '2.0.3'
2
+ VERSION = '2.0.4'
3
3
  end
@@ -46,6 +46,7 @@ describe Libuv::Async do
46
46
  @loop.stop
47
47
  end
48
48
  stopper.start(1000)
49
+ callback.close
49
50
  end
50
51
 
51
52
  @loop.work(proc {
@@ -0,0 +1,35 @@
1
+ require 'libuv'
2
+
3
+
4
+ describe Libuv::Listener do
5
+ it "should ensure there are no remaining object references in callbacks" do
6
+ require 'objspace'
7
+
8
+ checked = []
9
+
10
+ # These are created by loop objects and are never cleaned up
11
+ # This is OK as the loops are expected to execute for the life of the application
12
+ except = [::Libuv::Async, ::Libuv::Timer]
13
+
14
+ ObjectSpace.each_object(Class) do |cls|
15
+ next unless cls.ancestors.include? ::Libuv::Handle
16
+ next if checked.include? cls
17
+ checked << cls
18
+
19
+ values = cls.callback_lookup.values
20
+ values.select! {|val| except.include?(val.class) ? false : val.class }
21
+
22
+ if values.length > 0
23
+ puts "\nMemory Leak in #{cls} with #{values.length} left over objects"
24
+ puts "\nChecked #{checked.length} classes"
25
+ puts "\n\nObjects are:"
26
+ values.each do |val|
27
+ puts "\n#{val}\n"
28
+ end
29
+ raise 'Free the machines!'
30
+ end
31
+ end
32
+
33
+ expect(checked.length).to be > 3
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libuv
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bulat Shakirzyanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-20 00:00:00.000000000 Z
12
+ date: 2015-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -490,6 +490,7 @@ files:
490
490
  - spec/pipe_spec.rb
491
491
  - spec/tcp_spec.rb
492
492
  - spec/udp_spec.rb
493
+ - spec/zen_spec.rb
493
494
  homepage: https://github.com/cotag/libuv
494
495
  licenses:
495
496
  - MIT
@@ -525,4 +526,5 @@ test_files:
525
526
  - spec/pipe_spec.rb
526
527
  - spec/tcp_spec.rb
527
528
  - spec/udp_spec.rb
529
+ - spec/zen_spec.rb
528
530
  has_rdoc: