more timeouts
This commit is contained in:
parent
666291155c
commit
80ece7e427
1 changed files with 92 additions and 54 deletions
|
|
@ -71,19 +71,9 @@ end
|
||||||
|
|
||||||
def get_articles(cachedir=false)
|
def get_articles(cachedir=false)
|
||||||
for server in @connections.keys
|
for server in @connections.keys
|
||||||
begin
|
first, last = get_group_info(server, @group)
|
||||||
resp, count, first, last, name = @connections[server]["nntp"].group(@group)
|
|
||||||
@connections[server]["first"] = first ? first : 0
|
@connections[server]["first"] = first ? first : 0
|
||||||
@connections[server]["last"] = last ? last : 0
|
@connections[server]["last"] = last ? last : 0
|
||||||
rescue Net::NNTP::RuntimeError
|
|
||||||
print "Couldn't open group: #{@group}\n"
|
|
||||||
return false
|
|
||||||
rescue Errno::EPIPE, Errno::ECONNRESET
|
|
||||||
print "Caught Errno::EPIPE reading from server #{server}\n"
|
|
||||||
print "Error: #{$!}\n"
|
|
||||||
reconnect(server)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
read_cache(cachedir)
|
read_cache(cachedir)
|
||||||
for server in @connections.keys
|
for server in @connections.keys
|
||||||
|
|
@ -102,17 +92,11 @@ def get_articles(cachedir=false)
|
||||||
unless rangelist == nil or rangelist =~ /^$/
|
unless rangelist == nil or rangelist =~ /^$/
|
||||||
for i in rangelist.split(',')
|
for i in rangelist.split(',')
|
||||||
print "i: #{i}\n" if Debuglevel > 1
|
print "i: #{i}\n" if Debuglevel > 1
|
||||||
begin
|
resp, subj_lines = get_xhdr(server, i, "subject")
|
||||||
resp, subj_lines = @connections[server]["nntp"].xhdr("subject", i)
|
next unless resp
|
||||||
unless resp.to_i >= 200 and resp.to_i < 300
|
resp, messid_lines = get_xhdr(server, i, "message-id")
|
||||||
print "got response #{resp} while reading group #{@group} from #{server}\n"
|
next unless resp
|
||||||
return false
|
|
||||||
end
|
|
||||||
resp, messid_lines = @connections[server]["nntp"].xhdr("message-id", i)
|
|
||||||
unless resp.to_i >=200 and resp.to_i < 300
|
|
||||||
print "got response #{resp} while reading group #{@group} from #{server}\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
art = {}
|
art = {}
|
||||||
subj_lines.collect{|x|
|
subj_lines.collect{|x|
|
||||||
art[x[0]] = {} unless art.has_key?(x[0])
|
art[x[0]] = {} unless art.has_key?(x[0])
|
||||||
|
|
@ -130,17 +114,75 @@ def get_articles(cachedir=false)
|
||||||
add(art[id]["messid"], id, server, art[id]["subject"])
|
add(art[id]["messid"], id, server, art[id]["subject"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
save_cache(cachedir)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_group_info(server, group)
|
||||||
|
timedout = 0
|
||||||
|
resp = ""
|
||||||
|
first = ""
|
||||||
|
last = ""
|
||||||
|
begin
|
||||||
|
if timedout > 1
|
||||||
|
print "Too many timeouts!\n"
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
timeout(180) do
|
||||||
|
begin
|
||||||
|
resp, count, first, last, name = @connections[server]["nntp"].group(group)
|
||||||
|
rescue Net::NNTP::RuntimeError
|
||||||
|
print "Couldn't open group: #{group}\n"
|
||||||
|
return false
|
||||||
|
rescue Errno::EPIPE, Errno::ECONNRESET
|
||||||
|
print "Caught Errno::EPIPE reading from server #{server}\n"
|
||||||
|
print "Error: #{$!}\n"
|
||||||
|
retry if reconnect(server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return first, last if resp
|
||||||
|
rescue TimeoutError
|
||||||
|
print "Time out, reconnecting to server\n"
|
||||||
|
timedout += 1
|
||||||
|
retry if reconnect(server)
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_xhdr(server, range, header)
|
||||||
|
timedout = 0
|
||||||
|
resp = ""
|
||||||
|
lines = []
|
||||||
|
begin
|
||||||
|
if timedout > 1
|
||||||
|
print "Too many timeouts!\n"
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
timeout(180) do
|
||||||
|
begin
|
||||||
|
resp, lines = @connections[server]["nntp"].xhdr(header, range)
|
||||||
|
unless resp.to_i >= 200 and resp.to_i < 300
|
||||||
|
print "got response #{resp} while reading group #{@group} from #{server}\n"
|
||||||
|
return false
|
||||||
|
end
|
||||||
rescue Net::NNTP::RuntimeError
|
rescue Net::NNTP::RuntimeError
|
||||||
print "Caught Net::NNTP::RuntimeError reading from server #{server}\n"
|
print "Caught Net::NNTP::RuntimeError reading from server #{server}\n"
|
||||||
print "Error: #{$!}\n"
|
print "Error: #{$!}\n"
|
||||||
rescue Errno::EPIPE, Errno::ECONNRESET
|
rescue Errno::EPIPE, Errno::ECONNRESET
|
||||||
print "Caught Errno::EPIPE reading from server #{server}\n"
|
print "Caught Errno::EPIPE reading from server #{server}\n"
|
||||||
print "Error: #{$!}\n"
|
print "Error: #{$!}\n"
|
||||||
reconnect(server)
|
retry if reconnect(server)
|
||||||
retry
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return resp, lines
|
||||||
|
rescue TimeoutError
|
||||||
|
print "Time out, reconnecting to server\n"
|
||||||
|
timedout += 1
|
||||||
|
retry if reconnect(server)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# if xhdr doesn't work, this should be used
|
# if xhdr doesn't work, this should be used
|
||||||
# for i in (range.diff(@connections[server]["skip_ids"]).elements)
|
# for i in (range.diff(@connections[server]["skip_ids"]).elements)
|
||||||
|
|
@ -161,9 +203,6 @@ def get_articles(cachedir=false)
|
||||||
# print "whoopsie couldn't stat #{i}\n" if Debuglevel > 1
|
# print "whoopsie couldn't stat #{i}\n" if Debuglevel > 1
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
end
|
|
||||||
save_cache(cachedir)
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_groups
|
def get_groups
|
||||||
group_subjects unless @grouped
|
group_subjects unless @grouped
|
||||||
|
|
@ -189,7 +228,7 @@ def get_body(server, message)
|
||||||
begin
|
begin
|
||||||
resp, id, messid, list = @connections[server]["nntp"].body(message)
|
resp, id, messid, list = @connections[server]["nntp"].body(message)
|
||||||
rescue Net::NNTPReplyError
|
rescue Net::NNTPReplyError
|
||||||
print "Caught Net::NNTPReplyError reading article #{messid} from #{server}\n"
|
print "Caught Net::NNTPReplyError reading article #{message} from #{server}\n"
|
||||||
print "Error: #{$!}\n"
|
print "Error: #{$!}\n"
|
||||||
return false
|
return false
|
||||||
rescue Errno::EPIPE, Errno::ECONNRESET
|
rescue Errno::EPIPE, Errno::ECONNRESET
|
||||||
|
|
@ -202,9 +241,8 @@ def get_body(server, message)
|
||||||
return resp, id, messid, list
|
return resp, id, messid, list
|
||||||
rescue TimeoutError
|
rescue TimeoutError
|
||||||
print "Time out, reconnecting to server\n"
|
print "Time out, reconnecting to server\n"
|
||||||
reconnect(server)
|
|
||||||
timedout += 1
|
timedout += 1
|
||||||
retry
|
retry if reconnect(server)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue