48: def get_session(env, session_id)
49: @mutex.lock if env['rack.multithread']
50: unless session_id and session = @pool.get(session_id)
51: session_id, session = generate_sid, {}
52: unless /^STORED/ =~ @pool.add(session_id, session)
53: raise "Session collision on '#{session_id.inspect}'"
54: end
55: end
56: session.instance_variable_set '@old', @pool.get(session_id, true)
57: return [session_id, session]
58: rescue MemCache::MemCacheError, Errno::ECONNREFUSED
59:
60: warn "#{self} is unable to find memcached server."
61: warn $!.inspect
62: return [ nil, {} ]
63: ensure
64: @mutex.unlock if @mutex.locked?
65: end