dalli 3.2.4 → 3.2.5

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: e182f80ca3d5c567c59e32d7396f0c347ad79633672af15d6f231950909f12dd
4
- data.tar.gz: 92ddb5854da64ce59fb07c2eae7e1c1ce94d36868d26776c6415d20569dc0466
3
+ metadata.gz: bc1fc3d1639a4e5380a972472d830cd6999f016672af936701201521433180e3
4
+ data.tar.gz: 154207a695751bf6430f597783a6382bcb764f42e6f71303b2ead07f90e90f24
5
5
  SHA512:
6
- metadata.gz: 89b2f797e3abe759ddb154c10c91cfe4126341c0bd95202637e8ff67845a02669e0be4cdfc486679e45322f31976b41a404f7223b03042107aab8db3011414c5
7
- data.tar.gz: 4bc8eb1c4b478b946e202709d9d20995ebcb894ab32b5be070a19f99cecdfbd5ff0219344fe7288710202159a1b33298c1408e878a39cf256086f892ea5c4d41
6
+ metadata.gz: 4f7c65a4528f180ff8ccad3d39f0197cd83d409830e188e59fc8a03075e7a61c71c111db409cbefa01fb26d6e408fae2e5f2701e4f370744bf33a08023c33831
7
+ data.tar.gz: cbd13ba3453f17eb012632f5d077552eb6ea46adbb349f4fb72b612c8d9fe2bb6a9b64641a2d105592d0def88ad7b467a1f007ed6abb76e8c0fdb8d94064c369
data/CHANGELOG.md CHANGED
@@ -4,11 +4,18 @@ Dalli Changelog
4
4
  Unreleased
5
5
  ==========
6
6
 
7
+
8
+ 3.2.5
9
+ ==========
10
+
11
+ - Better handle memcached requests being interrupted by Thread#raise or Thread#kill (byroot)
12
+ - Unexpected errors are no longer treated as `Dalli::NetworkError`, including errors raised by `Timeout.timeout` (byroot)
13
+
7
14
  3.2.4
8
15
  ==========
9
16
 
10
- - Cache PID calls for performance since glibc no longer caches in recent versions (casperisfine)
11
- - Preallocate the read buffer in Socket#readfull (casperisfine)
17
+ - Cache PID calls for performance since glibc no longer caches in recent versions (byroot)
18
+ - Preallocate the read buffer in Socket#readfull (byroot)
12
19
 
13
20
  3.2.3
14
21
  ==========
@@ -51,7 +58,7 @@ Unreleased
51
58
  3.1.4
52
59
  ==========
53
60
 
54
- - Improve response parsing performance (casperisfine)
61
+ - Improve response parsing performance (byroot)
55
62
  - Reorganize binary protocol parsing a bit (petergoldstein)
56
63
  - Fix handling of non-ASCII keys in get_multi (petergoldstein)
57
64
 
@@ -32,7 +32,13 @@ module Dalli
32
32
  verify_state(opkey)
33
33
 
34
34
  begin
35
- send(opkey, *args)
35
+ @connection_manager.start_request!
36
+ response = send(opkey, *args)
37
+
38
+ # pipelined_get emit query but doesn't read the response(s)
39
+ @connection_manager.finish_request! unless opkey == :pipelined_get
40
+
41
+ response
36
42
  rescue Dalli::MarshalError => e
37
43
  log_marshal_err(args.first, e)
38
44
  raise
@@ -40,7 +46,8 @@ module Dalli
40
46
  raise
41
47
  rescue StandardError => e
42
48
  log_unexpected_err(e)
43
- down!
49
+ close
50
+ raise
44
51
  end
45
52
  end
46
53
 
@@ -65,10 +72,9 @@ module Dalli
65
72
  #
66
73
  # Returns nothing.
67
74
  def pipeline_response_setup
68
- verify_state(:getkq)
75
+ verify_pipelined_state(:getkq)
69
76
  write_noop
70
77
  response_buffer.reset
71
- @connection_manager.start_request!
72
78
  end
73
79
 
74
80
  # Attempt to receive and parse as many key/value pairs as possible
@@ -169,6 +175,11 @@ module Dalli
169
175
  raise_down_error unless ensure_connected!
170
176
  end
171
177
 
178
+ def verify_pipelined_state(_opkey)
179
+ @connection_manager.confirm_in_progress!
180
+ raise_down_error unless connected?
181
+ end
182
+
172
183
  # The socket connection to the underlying server is initialized as a side
173
184
  # effect of this call. In fact, this is the ONLY place where that
174
185
  # socket connection is initialized.
@@ -54,6 +54,7 @@ module Dalli
54
54
 
55
55
  @sock = memcached_socket
56
56
  @pid = PIDCache.pid
57
+ @request_in_progress = false
57
58
  rescue SystemCallError, Timeout::Error, EOFError, SocketError => e
58
59
  # SocketError = DNS resolution failure
59
60
  error_on_request!(e)
@@ -98,7 +99,13 @@ module Dalli
98
99
  end
99
100
 
100
101
  def confirm_ready!
101
- error_on_request!(RuntimeError.new('Already writing to socket')) if request_in_progress?
102
+ close if request_in_progress?
103
+ close_on_fork if fork_detected?
104
+ end
105
+
106
+ def confirm_in_progress!
107
+ raise '[Dalli] No request in progress. This may be a bug in Dalli.' unless request_in_progress?
108
+
102
109
  close_on_fork if fork_detected?
103
110
  end
104
111
 
@@ -124,10 +131,14 @@ module Dalli
124
131
  end
125
132
 
126
133
  def start_request!
134
+ raise '[Dalli] Request already in progress. This may be a bug in Dalli.' if @request_in_progress
135
+
127
136
  @request_in_progress = true
128
137
  end
129
138
 
130
139
  def finish_request!
140
+ raise '[Dalli] No request in progress. This may be a bug in Dalli.' unless @request_in_progress
141
+
131
142
  @request_in_progress = false
132
143
  end
133
144
 
@@ -136,36 +147,26 @@ module Dalli
136
147
  end
137
148
 
138
149
  def read_line
139
- start_request!
140
150
  data = @sock.gets("\r\n")
141
151
  error_on_request!('EOF in read_line') if data.nil?
142
- finish_request!
143
152
  data
144
153
  rescue SystemCallError, Timeout::Error, EOFError => e
145
154
  error_on_request!(e)
146
155
  end
147
156
 
148
157
  def read(count)
149
- start_request!
150
- data = @sock.readfull(count)
151
- finish_request!
152
- data
158
+ @sock.readfull(count)
153
159
  rescue SystemCallError, Timeout::Error, EOFError => e
154
160
  error_on_request!(e)
155
161
  end
156
162
 
157
163
  def write(bytes)
158
- start_request!
159
- result = @sock.write(bytes)
160
- finish_request!
161
- result
164
+ @sock.write(bytes)
162
165
  rescue SystemCallError, Timeout::Error => e
163
166
  error_on_request!(e)
164
167
  end
165
168
 
166
- # Non-blocking read. Should only be used in the context
167
- # of a caller who has called start_request!, but not yet
168
- # called finish_request!. Here to support the operation
169
+ # Non-blocking read. Here to support the operation
169
170
  # of the get_multi operation
170
171
  def read_nonblock
171
172
  @sock.read_available
data/lib/dalli/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dalli
4
- VERSION = '3.2.4'
4
+ VERSION = '3.2.5'
5
5
 
6
6
  MIN_SUPPORTED_MEMCACHED_VERSION = '1.4'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter M. Goldstein
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-17 00:00:00.000000000 Z
12
+ date: 2023-06-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: High performance memcached client for Ruby
15
15
  email:
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.4.5
78
+ rubygems_version: 3.4.14
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: High performance memcached client for Ruby