fix threading problems?
This commit is contained in:
parent
a06ece8c56
commit
3767681c02
1 changed files with 61 additions and 84 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/ruby -w
|
#!/usr/local/bin/ruby -w
|
||||||
|
|
||||||
# $Dwarf: ripnews.rb,v 1.94 2005/02/01 19:35:49 ward Exp $
|
# $Dwarf: ripnews.rb,v 1.95 2005/02/01 22:09:22 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -384,61 +384,11 @@ end
|
||||||
|
|
||||||
def get_multi(subj, group)
|
def get_multi(subj, group)
|
||||||
print "Fetching multipart article: #{subj}\n"
|
print "Fetching multipart article: #{subj}\n"
|
||||||
if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == ""
|
|
||||||
body = @articles.get_group_body(subj)
|
|
||||||
|
|
||||||
# should probably thread this too, but I never use this
|
|
||||||
|
|
||||||
if UUEncode.is_uuencoded(body)
|
|
||||||
filename = UUEncode.get_filename(body)
|
|
||||||
print " filename #{filename}\n"
|
|
||||||
unless check_ext(group, filename, "m", subj)
|
|
||||||
print " Skipping article...\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
print " UUDecoding...\n"
|
|
||||||
mode, filename, body = UUEncode.uudecode(body)
|
|
||||||
elsif YEnc.is_yencoded(body)
|
|
||||||
print "yencc\n"
|
|
||||||
filename = YEnc.get_filename(body)
|
|
||||||
print "filename #{filename}\n"
|
|
||||||
unless check_ext(group, filename, "m", subj)
|
|
||||||
print " Skipping article...\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
print " YDecoding...\n"
|
|
||||||
begin
|
|
||||||
mode, filename, body = YEnc.ydecode(body)
|
|
||||||
rescue YencError
|
|
||||||
# XXX if there is a yenc problem I want the data so I can research it
|
|
||||||
output_data(subj, 0600, "YencProblem", body)
|
|
||||||
# XXX return succes even though it's not true
|
|
||||||
return true
|
|
||||||
rescue PermError
|
|
||||||
print "#{$!}\n"
|
|
||||||
print " Skipping article...\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
print " Unknown encoding (not UU, not yEnc), skipping...\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
if mode == false
|
|
||||||
print " Decoding failed skipping article...\n"
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
output_data(subj, mode, filename, body)
|
|
||||||
|
|
||||||
# end of thread
|
|
||||||
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
body = @articles.get_group_body_first(subj)
|
body = @articles.get_group_body_first(subj)
|
||||||
if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body)
|
if UUEncode.is_uuencoded(body) or YEnc.is_yencoded(body)
|
||||||
if UUEncode.is_uuencoded(body)
|
if UUEncode.is_uuencoded(body)
|
||||||
filename = UUEncode.get_filename(body)
|
filename = UUEncode.get_filename(body)
|
||||||
print " filename #{filename}\n"
|
print " filename #{filename}\n"
|
||||||
return false unless check_ext(group, filename, "m", subj)
|
|
||||||
unless check_ext(group, filename, "m", subj)
|
unless check_ext(group, filename, "m", subj)
|
||||||
print " Skipping article...\n"
|
print " Skipping article...\n"
|
||||||
return false
|
return false
|
||||||
|
|
@ -452,6 +402,15 @@ def get_multi(subj, group)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == ""
|
||||||
|
bodyrest = @articles.get_group_body_rest(subj)
|
||||||
|
unless bodyrest
|
||||||
|
print " Skipping article...\n"
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
body.concat(bodyrest)
|
||||||
|
else
|
||||||
file = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
file = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||||
body.collect{|x| file.print "#{x}\n"}
|
body.collect{|x| file.print "#{x}\n"}
|
||||||
|
|
||||||
|
|
@ -460,24 +419,44 @@ def get_multi(subj, group)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
fileout = Tempfile.new("riptmp", @config[group]["TEMPDIR"])
|
||||||
|
end
|
||||||
|
|
||||||
# I think a thread should start about here
|
|
||||||
@decode_threads << Thread.new(body, file, fileout, subj) do |tbody, tfile, tfileout, tsubj|
|
@decode_threads << Thread.new(body, file, fileout, subj) do |tbody, tfile, tfileout, tsubj|
|
||||||
# imediately stop to continue with main program
|
# imediately stop to continue with main program
|
||||||
Thread.stop
|
Thread.stop
|
||||||
puts "inside thread\n"
|
puts "inside thread\n"
|
||||||
if UUEncode.is_uuencoded(tbody)
|
if UUEncode.is_uuencoded(tbody)
|
||||||
print " UUDecoding...\n"
|
print " UUDecoding...\n"
|
||||||
mode, filename, body = UUEncode.uudecode(tfile, tfileout)
|
if tfile
|
||||||
elsif YEnc.is_yencoded(body)
|
mode, filename, tbody = UUEncode.uudecode(tfile, tfileout)
|
||||||
|
else
|
||||||
|
mode, filename, tbody = UUEncode.uudecode(tbody)
|
||||||
|
end
|
||||||
|
elsif YEnc.is_yencoded(tbody)
|
||||||
print " YDecoding...\n"
|
print " YDecoding...\n"
|
||||||
mode, filename, body = YEnc.ydecode(tfile, tfileout)
|
begin
|
||||||
|
if tfile
|
||||||
|
mode, filename, tbody = YEnc.ydecode(tfile, tfileout)
|
||||||
|
else
|
||||||
|
mode, filename, tbody = YEnc.ydecode(tbody)
|
||||||
|
end
|
||||||
|
rescue YencError
|
||||||
|
# XXX if there is a yenc problem I want the data so I can research it
|
||||||
|
output_data(subj, 0600, "YencProblem", tbody)
|
||||||
|
# XXX return succes even though it's not true
|
||||||
|
return true
|
||||||
|
rescue PermError
|
||||||
|
print "#{$!}\n"
|
||||||
|
print " Skipping article...\n"
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if mode == false
|
if mode == false
|
||||||
print " Decoding failed skipping article...\n"
|
print " Decoding failed skipping article...\n"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if tfile
|
||||||
# horrible cheat to not lose the outputted file
|
# horrible cheat to not lose the outputted file
|
||||||
tbody = tfileout.path
|
tbody = tfileout.path
|
||||||
bodybase = tbody.sub(/\/[^\/]*$/, "/ripnewsdecode")
|
bodybase = tbody.sub(/\/[^\/]*$/, "/ripnewsdecode")
|
||||||
|
|
@ -487,12 +466,11 @@ def get_multi(subj, group)
|
||||||
end
|
end
|
||||||
File.move(tbody, "#{bodybase}-#{i}")
|
File.move(tbody, "#{bodybase}-#{i}")
|
||||||
tbody = "#{bodybase}-#{i}"
|
tbody = "#{bodybase}-#{i}"
|
||||||
file.close
|
tfile.close
|
||||||
fileout.close(false)
|
tfileout.close(false)
|
||||||
|
|
||||||
output_data(tsubj, mode, filename, tbody)
|
|
||||||
end
|
end
|
||||||
# thread could end here
|
output_data(tsubj, mode, filename, tbody)
|
||||||
|
end # thread end
|
||||||
|
|
||||||
@decode_threads.each{ |thr|
|
@decode_threads.each{ |thr|
|
||||||
if thr.status == "sleep" # and fire up the threads again
|
if thr.status == "sleep" # and fire up the threads again
|
||||||
|
|
@ -511,7 +489,6 @@ def get_multi(subj, group)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def fill_preselector(group)
|
def fill_preselector(group)
|
||||||
if @config[group].has_key?("-I")
|
if @config[group].has_key?("-I")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue