lib/rack/session/memcache.rb in rack-1.5.5 vs lib/rack/session/memcache.rb in rack-1.6.0.beta
- old
+ new
@@ -45,11 +45,11 @@
break sid unless @pool.get(sid, true)
end
end
def get_session(env, sid)
- with_lock(env, [nil, {}]) do
+ with_lock(env) do
unless sid and session = @pool.get(sid)
sid, session = generate_sid, {}
unless /^STORED/ =~ @pool.add(sid, session)
raise "Session collision on '#{sid.inspect}'"
end
@@ -60,11 +60,11 @@
def set_session(env, session_id, new_session, options)
expiry = options[:expire_after]
expiry = expiry.nil? ? 0 : expiry + 1
- with_lock(env, false) do
+ with_lock(env) do
@pool.set session_id, new_session, expiry
session_id
end
end
@@ -73,18 +73,18 @@
@pool.delete(session_id)
generate_sid unless options[:drop]
end
end
- def with_lock(env, default=nil)
+ def with_lock(env)
@mutex.lock if env['rack.multithread']
yield
rescue MemCache::MemCacheError, Errno::ECONNREFUSED
if $VERBOSE
warn "#{self} is unable to find memcached server."
warn $!.inspect
end
- default
+ raise
ensure
@mutex.unlock if @mutex.locked?
end
end