ethon 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/lib/ethon/curl.rb +23 -2
- data/lib/ethon/curls/functions.rb +2 -1
- data/lib/ethon/easy/operations.rb +10 -0
- data/lib/ethon/multi/operations.rb +4 -1
- data/lib/ethon/version.rb +1 -1
- data/spec/ethon/curl_spec.rb +10 -0
- data/spec/ethon/easy/operations_spec.rb +5 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YThkNDc2ZmViYTdlZDkxNWUxMjRiNmE5NzIyNDUyN2QxMDlkNDc2MA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f2d076d0f8210b0e2ac4f9a798b6f7091bc72e1
|
4
|
+
data.tar.gz: e4e029697e2da2f8f0ff32eeae74dbe52b37342c
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YWY1NzBmZTIyYTFlY2I2M2ZlMzhmMDk1ZWJiNDk2MDlhODJhMTg1ZWVhM2Yy
|
11
|
-
MjM5ODJjNWI0MTY3MWU0NzkxZTFkNWQ0YTdkZGJhMmY1YzdmYzc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MmZiN2MxYmQyYmM4YWExOTIxYzU4NDlkYWRhYmE0M2RlZWIzOGJlY2IwOThm
|
14
|
-
MzkyZGQ0OGMzOTQyZWE0ZjZhODU5ZTlkMjk3ZWFjZGI2Y2E0NzZiOTM3ZjFl
|
15
|
-
NTkyMzYzNDQ2NWRjY2FkOWJjMDVjZGFkZmRmZDE3ZmI3ZjRmYTg=
|
6
|
+
metadata.gz: 44c3c55ce791f04ab8c0722b91473a0f16b897da96312b3f660e20929dfcaef3d961dedcb21b08cee0a08b152f597883cf6f02de23d912379237a3cf7b14e1dc
|
7
|
+
data.tar.gz: 87306062771ee5c5fe442bb041b1b03aa55ae200fff87e65fe00ecf390b6e41212dc961973b71560d74c769ab5fb3c639a42182b41d6576822cde797c219e68b
|
data/lib/ethon/curl.rb
CHANGED
@@ -31,7 +31,7 @@ module Ethon
|
|
31
31
|
@blocking = true
|
32
32
|
|
33
33
|
@@initialized = false
|
34
|
-
@@
|
34
|
+
@@curl_mutex = Mutex.new
|
35
35
|
|
36
36
|
class << self
|
37
37
|
# This function sets up the program environment that libcurl needs.
|
@@ -55,7 +55,7 @@ module Ethon
|
|
55
55
|
#
|
56
56
|
# @raise [ Ethon::Errors::GlobalInit ] If Curl.global_init fails.
|
57
57
|
def init
|
58
|
-
@@
|
58
|
+
@@curl_mutex.synchronize {
|
59
59
|
if not @@initialized
|
60
60
|
raise Errors::GlobalInit.new if Curl.global_init(GLOBAL_ALL) != 0
|
61
61
|
@@initialized = true
|
@@ -63,6 +63,27 @@ module Ethon
|
|
63
63
|
end
|
64
64
|
}
|
65
65
|
end
|
66
|
+
|
67
|
+
# This function releases resources acquired by curl_global_init.
|
68
|
+
# You should call curl_global_cleanup once for each call you make to
|
69
|
+
# curl_global_init, after you are done using libcurl.
|
70
|
+
# This function is not thread safe. You must not call it when any other thread in the
|
71
|
+
# program (i.e. a thread sharing the same memory) is running. This doesn't just
|
72
|
+
# mean no other thread that is using libcurl. Because curl_global_cleanup calls functions of other
|
73
|
+
# libraries that are similarly thread unsafe, it could conflict with
|
74
|
+
# any other thread that uses these other libraries.
|
75
|
+
# See the description in libcurl of global environment requirements
|
76
|
+
# for details of how to use this function.
|
77
|
+
def cleanup
|
78
|
+
@@curl_mutex.synchronize {
|
79
|
+
if @@initialized
|
80
|
+
Curl.global_cleanup()
|
81
|
+
@@initialized = false
|
82
|
+
Ethon.logger.debug("ETHON: Libcurl cleanup") if Ethon.logger
|
83
|
+
end
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
66
87
|
end
|
67
88
|
end
|
68
89
|
end
|
@@ -8,7 +8,8 @@ module Ethon
|
|
8
8
|
# :nodoc:
|
9
9
|
def self.extended(base)
|
10
10
|
base.attach_function :global_init, :curl_global_init, [:long], :int
|
11
|
-
base.attach_function :
|
11
|
+
base.attach_function :global_cleanup, :curl_global_cleanup, [], :void
|
12
|
+
base.attach_function :free, :curl_free, [:pointer], :void
|
12
13
|
|
13
14
|
base.attach_function :easy_init, :curl_easy_init, [], :pointer
|
14
15
|
base.attach_function :easy_cleanup, :curl_easy_cleanup, [:pointer], :void
|
@@ -26,6 +26,16 @@ module Ethon
|
|
26
26
|
@return_code
|
27
27
|
end
|
28
28
|
|
29
|
+
# Clean up the easy.
|
30
|
+
#
|
31
|
+
# @example Perform clean up.
|
32
|
+
# easy.cleanup
|
33
|
+
#
|
34
|
+
# @return the result of the free which is nil
|
35
|
+
def cleanup
|
36
|
+
handle.free
|
37
|
+
end
|
38
|
+
|
29
39
|
# Prepare the easy. Options, headers and callbacks
|
30
40
|
# were set.
|
31
41
|
#
|
@@ -124,7 +124,10 @@ module Ethon
|
|
124
124
|
else
|
125
125
|
@timeval[:sec] = timeout / 1000
|
126
126
|
@timeval[:usec] = (timeout * 1000) % 1000000
|
127
|
-
|
127
|
+
loop do
|
128
|
+
code = Curl.select(max_fd + 1, @fd_read, @fd_write, @fd_excep, @timeval)
|
129
|
+
break unless code < 0 && ::FFI.errno == Errno::EINTR::Errno
|
130
|
+
end
|
128
131
|
raise Errors::Select.new(::FFI.errno) if code < 0
|
129
132
|
end
|
130
133
|
end
|
data/lib/ethon/version.rb
CHANGED
data/spec/ethon/curl_spec.rb
CHANGED
@@ -23,5 +23,15 @@ describe Ethon::Curl do
|
|
23
23
|
Ethon::Curl.init
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
context "when global_cleanup is called" do
|
28
|
+
before { expect(Ethon::Curl).to receive(:global_cleanup) }
|
29
|
+
|
30
|
+
it "logs" do
|
31
|
+
expect(Ethon.logger).to receive(:debug).twice
|
32
|
+
Ethon::Curl.init
|
33
|
+
Ethon::Curl.cleanup
|
34
|
+
end
|
35
|
+
end
|
26
36
|
end
|
27
37
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hans Hasselberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.3.0
|
27
27
|
description: Very lightweight libcurl wrapper.
|
@@ -31,9 +31,9 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
35
|
-
- .rspec
|
36
|
-
- .travis.yml
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".travis.yml"
|
37
37
|
- CHANGELOG.md
|
38
38
|
- Gemfile
|
39
39
|
- Guardfile
|
@@ -143,12 +143,12 @@ require_paths:
|
|
143
143
|
- lib
|
144
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
145
|
requirements:
|
146
|
-
- -
|
146
|
+
- - ">="
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0'
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- -
|
151
|
+
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: 1.3.6
|
154
154
|
requirements: []
|