diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-11 10:51:44 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-11 23:42:25 +0000 |
commit | d9b4aa1ad01a0506a544eaabe02a9852d01d5d4f (patch) | |
tree | 66d5c72080042b1bb6fa0ffed3fefbfe6ba6a3fa | |
parent | df3064c1cd63a9f626938f1dcde44f1909971a59 (diff) | |
download | mogilefs-client-d9b4aa1ad01a0506a544eaabe02a9852d01d5d4f.tar.gz |
Otherwise it's outright painful to figure out what failed in a pipeline...
-rw-r--r-- | lib/mogilefs/backend.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb index 24ce81a..89f88a3 100644 --- a/lib/mogilefs/backend.rb +++ b/lib/mogilefs/backend.rb @@ -178,7 +178,7 @@ class MogileFS::Backend raise MogileFS::PipelineError, "EOF with #{@pending.size} requests in-flight" ready = @pending.shift - ready.call(parse_response(line, false)) + ready[1].call(parse_response(line, ready[0])) end def timeout_update(timeout, t0) # :nodoc: @@ -221,7 +221,7 @@ class MogileFS::Backend # send the request out... begin io.timed_write(request, timeout) - @pending << block + @pending << [ request, block ] rescue SystemCallError, MogileFS::RequestTruncatedError => err @dead[@active_host] = [ Time.now, err ] shutdown_unlocked(@pending[0]) @@ -254,7 +254,7 @@ class MogileFS::Backend @mutex.synchronize do begin io = dispatch_unlocked(request) - line = io.timed_gets(@timeout) and return parse_response(line, true) + line = io.timed_gets(@timeout) and return parse_response(line) idempotent or raise EOFError, "end of file reached after: #{request.inspect}" @@ -290,13 +290,16 @@ class MogileFS::Backend # Turns the +line+ response from the server into a Hash of options, an # error, or raises, as appropriate. - def parse_response(line, raise_ok = true) + def parse_response(line, request = nil) if line =~ /^ERR\s+(\w+)\s*([^\r\n]*)/ @lasterr = $1 @lasterrstr = $2 ? url_unescape($2) : nil - e = error(@lasterr).new(@lasterrstr) - raise e if raise_ok - return e + if request + request = " request=#{request.strip}" + @lasterrstr = @lasterrstr ? (@lasterrstr << request) : request + return error(@lasterr).new(@lasterrstr) + end + raise error(@lasterr).new(@lasterrstr) end return url_decode($1) if line =~ /^OK\s+\d*\s*(\S*)\r\n\z/ |