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
|
||||
|
||||
# $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$
|
||||
|
||||
#
|
||||
|
|
@ -26,6 +26,7 @@ require 'getoptlong'
|
|||
require 'news/article'
|
||||
require 'news/newsrc'
|
||||
require 'tempfile'
|
||||
require 'thread'
|
||||
require 'encode/uuencode'
|
||||
require 'encode/yenc'
|
||||
|
||||
|
|
@ -385,6 +386,9 @@ def get_multi(subj, group)
|
|||
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"
|
||||
|
|
@ -420,6 +424,9 @@ def get_multi(subj, group)
|
|||
return false
|
||||
end
|
||||
output_data(subj, mode, filename, body)
|
||||
|
||||
# end of thread
|
||||
|
||||
return true
|
||||
else
|
||||
body = @articles.get_group_body_first(subj)
|
||||
|
|
@ -535,8 +542,10 @@ def output_data(subject, mode, filename="", body="")
|
|||
|
||||
# do the actual saving
|
||||
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
||||
@articles.group_update_newsrc(subject)
|
||||
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
||||
@newsrc_lock.synchronize {
|
||||
@articles.group_update_newsrc(subject)
|
||||
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -646,6 +655,7 @@ def main
|
|||
profile_mem("out side of loop still")
|
||||
for group in @config.keys.sort
|
||||
@decode_threads = []
|
||||
@newsrc_lock = Mutex.new
|
||||
profile_mem("#{group} start")
|
||||
puts "object count:"
|
||||
puts ObjectSpace.each_object(){}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue