What have you found for these years?

2009-03-12

MogileFS::MogileFS#get_file_data

updated:
修改 thumbo 不要用 get_file_data 比把他修好快:
don't use Mogilefs::Mogilefs#get_file_data, it's broken. detail:
* use curb and falls back to open-uri instead, wrapped with timeout.

[#24481] MogileFS::MogileFS#get_file_data can't read all data (sometimes)
[quote="me"]
http://git.bogomips.org/cgit/mogilefs-client.git/tree/lib/mogilefs/mogilefs.rb#n74
in lib/mogilefs/mogilefs.rb: 74,

return block_given? ? yield(sock) : sock.read

`sock.read' can't read all data from server sometimes.
Perhaps it needs IO.select([sock]) and read all
data until there's no remaining data.

I think we could use curb or something else and
falls back to net/http, instead of playing with
low level socket.

http://pivotallabs.com/users/steve/blog/articles/644-net-http-alternatives

Thanks!

Jen-Shin
[/quote]

這邊無視 timeout 的話,應該改成碰上 Errno::EAGAIN 重新
IO.select, 而接著一直 read 到沒有東西為止。
result = ''
begin
result << buff while (buff = sock.read).size != 0
return result
rescue Errno::EAGAIN
IO.select([sock])
retry
end

暫時用 curb 做 workaround 吧...
如:

timeout(@time){Curl::Easy.perform('godfat.org').body_str}

0 retries:

Post a Comment

All texts are licensed under CC Attribution 3.0