dalli 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dalli might be problematic. Click here for more details.

data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Dalli Changelog
2
2
  =====================
3
3
 
4
+ 0.9.2
5
+ ----
6
+
7
+ - Verify proper operation in Heroku.
8
+
4
9
  0.9.1
5
10
  ----
6
11
 
data/TODO.md CHANGED
@@ -3,4 +3,3 @@ TODO
3
3
 
4
4
  * More of the memcached instruction set. This will be done based on user demand. Email me if the API is missing a feature you'd like to use.
5
5
  * Better API documentation
6
- * SASL for Heroku memcached add-on support.
data/lib/dalli/client.rb CHANGED
@@ -21,7 +21,7 @@ module Dalli
21
21
  #
22
22
  def initialize(servers=nil, options={})
23
23
  @ring = Dalli::Ring.new(
24
- Array(servers || env_servers).map do |s|
24
+ Array(env_servers || servers).map do |s|
25
25
  Dalli::Server.new(s)
26
26
  end, options
27
27
  )
@@ -148,7 +148,7 @@ module Dalli
148
148
  end
149
149
 
150
150
  def env_servers
151
- ENV['MEMCACHE_SERVERS'].split(',')
151
+ ENV['MEMCACHE_SERVERS'] ? ENV['MEMCACHE_SERVERS'].split(',') : nil
152
152
  end
153
153
 
154
154
  # Chokepoint method for instrumentation
data/lib/dalli/server.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'socket'
2
+ require 'timeout'
2
3
 
3
4
  module Dalli
4
5
  class Server
@@ -263,16 +264,16 @@ module Dalli
263
264
  end
264
265
  end
265
266
 
266
- def read(count)
267
+ def read(count, socket=connection)
267
268
  begin
268
269
  value = ''
269
270
  begin
270
271
  loop do
271
- value << connection.sysread(count)
272
+ value << socket.sysread(count)
272
273
  break if value.size == count
273
274
  end
274
275
  rescue Errno::EAGAIN, Errno::EWOULDBLOCK
275
- if IO.select([connection], nil, nil, TIMEOUT)
276
+ if IO.select([socket], nil, nil, TIMEOUT)
276
277
  retry
277
278
  else
278
279
  raise Timeout::Error, "IO timeout"
@@ -381,14 +382,16 @@ module Dalli
381
382
  def sasl_authentication(socket)
382
383
  init_sasl if !defined?(::SASL)
383
384
 
385
+ Dalli.logger.info { "Dalli/SASL authenticating as #{username}" }
386
+
384
387
  # negotiate
385
388
  req = [REQUEST, OPCODES[:auth_negotiation], 0, 0, 0, 0, 0, 0, 0].pack(FORMAT[:noop])
386
389
  socket.write(req)
387
- header = socket.read(24)
390
+ header = read(24, socket)
388
391
  raise Dalli::NetworkError, 'No response' if !header
389
392
  (extras, status, count) = header.unpack(NORMAL_HEADER)
390
393
  raise Dalli::NetworkError, "Unexpected message format: #{extras} #{count}" unless extras == 0 && count > 0
391
- content = socket.read(count)
394
+ content = read(count, socket)
392
395
  return (Dalli.logger.debug("Authentication not required/supported by server")) if status == 0x81
393
396
  mechanisms = content.split(' ')
394
397
 
@@ -400,16 +403,16 @@ module Dalli
400
403
  req = [REQUEST, OPCODES[:auth_request], mechanism.size, 0, 0, 0, mechanism.size + msg.size, 0, 0, mechanism, msg].pack(FORMAT[:auth_request])
401
404
  socket.write(req)
402
405
 
403
- header = socket.read(24)
406
+ header = read(24, socket)
404
407
  raise Dalli::NetworkError, 'No response' if !header
405
408
  (extras, status, count) = header.unpack(NORMAL_HEADER)
406
409
  raise Dalli::NetworkError, "Unexpected message format: #{extras} #{count}" unless extras == 0 && count > 0
407
- content = socket.read(count)
410
+ content = read(count, socket)
411
+ return Dalli.logger.info("Dalli/SASL: #{content}") if status == 0
412
+
408
413
  raise Dalli::NetworkError, "Error authenticating: #{status}" unless status == 0x21
409
414
  (step, msg) = sasl.receive('challenge', content)
410
415
  raise Dalli::NetworkError, "Authentication failed" if sasl.failed? || step != 'response'
411
-
412
-
413
416
  end
414
417
  end
415
418
  end
data/lib/dalli/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dalli
2
- VERSION = '0.9.1'
2
+ VERSION = '0.9.2'
3
3
  end
data/test/test_network.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestNetwork < Test::Unit::TestCase
4
-
4
+
5
5
  context 'assuming a bad network' do
6
6
 
7
7
  should 'handle connection refused' do
@@ -10,12 +10,12 @@ class TestNetwork < Test::Unit::TestCase
10
10
  dc.get 'foo'
11
11
  end
12
12
  end
13
-
13
+
14
14
  context 'with a fake server' do
15
15
 
16
16
  should 'handle connection reset' do
17
17
  memcached_mock(lambda {|sock| sock.close }) do
18
- assert_error Dalli::NetworkError, /ECONNRESET/ do
18
+ assert_error Dalli::NetworkError, /ECONNRESET|EOFError/ do
19
19
  dc = Dalli::Client.new('localhost:19123')
20
20
  dc.get('abc')
21
21
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 1
9
- version: 0.9.1
8
+ - 2
9
+ version: 0.9.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mike Perham