some mutex locking
This commit is contained in:
parent
d68c916e89
commit
cd03bf9469
1 changed files with 13 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/ruby -w
|
#!/usr/local/bin/ruby -w
|
||||||
|
|
||||||
# $Dwarf: ripnews.rb,v 1.88 2005/01/29 18:42:30 ward Exp $
|
# $Dwarf: ripnews.rb,v 1.89 2005/01/30 14:24:47 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -26,6 +26,7 @@ require 'getoptlong'
|
||||||
require 'news/article'
|
require 'news/article'
|
||||||
require 'news/newsrc'
|
require 'news/newsrc'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
|
require 'thread'
|
||||||
require 'encode/uuencode'
|
require 'encode/uuencode'
|
||||||
require 'encode/yenc'
|
require 'encode/yenc'
|
||||||
|
|
||||||
|
|
@ -385,6 +386,9 @@ 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"] == ""
|
if @config[group]["TEMPDIR"] == nil or @config[group]["TEMPDIR"] == ""
|
||||||
body = @articles.get_group_body(subj)
|
body = @articles.get_group_body(subj)
|
||||||
|
|
||||||
|
# should probably thread this too, but I never use this
|
||||||
|
|
||||||
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"
|
||||||
|
|
@ -420,6 +424,9 @@ def get_multi(subj, group)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
output_data(subj, mode, filename, body)
|
output_data(subj, mode, filename, body)
|
||||||
|
|
||||||
|
# end of thread
|
||||||
|
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
body = @articles.get_group_body_first(subj)
|
body = @articles.get_group_body_first(subj)
|
||||||
|
|
@ -535,8 +542,10 @@ def output_data(subject, mode, filename="", body="")
|
||||||
|
|
||||||
# do the actual saving
|
# do the actual saving
|
||||||
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
||||||
|
@newsrc_lock.synchronize {
|
||||||
@articles.group_update_newsrc(subject)
|
@articles.group_update_newsrc(subject)
|
||||||
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -646,6 +655,7 @@ def main
|
||||||
profile_mem("out side of loop still")
|
profile_mem("out side of loop still")
|
||||||
for group in @config.keys.sort
|
for group in @config.keys.sort
|
||||||
@decode_threads = []
|
@decode_threads = []
|
||||||
|
@newsrc_lock = Mutex.new
|
||||||
profile_mem("#{group} start")
|
profile_mem("#{group} start")
|
||||||
puts "object count:"
|
puts "object count:"
|
||||||
puts ObjectSpace.each_object(){}
|
puts ObjectSpace.each_object(){}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue