diff options
author | Luke Kanies <luke@madstop.com> | 2008-11-28 11:23:17 -0600 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-12-02 09:20:09 +1100 |
commit | 9ab3afb5423b406c661805946aac174f7f3e5674 (patch) | |
tree | 7346661f9fb3b6948b79fa5a5c7d972d8261596f /lib/puppet | |
parent | 3fe9cc748a7bca9b5fead1f9c1e0d82f1207bb3f (diff) | |
download | puppet-9ab3afb5423b406c661805946aac174f7f3e5674.tar.gz puppet-9ab3afb5423b406c661805946aac174f7f3e5674.tar.xz puppet-9ab3afb5423b406c661805946aac174f7f3e5674.zip |
Hopefully fixing #1703 - using a mutex around the sending of the tagmails
It's not really possible to test that this fixes the problem, and
I can't even reproduce it, but hopefully this will work.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/reports/tagmail.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb index 102647c66..fa4e536e1 100644 --- a/lib/puppet/reports/tagmail.rb +++ b/lib/puppet/reports/tagmail.rb @@ -151,12 +151,14 @@ Puppet::Reports.register_report(:tagmail) do reports.each do |emails, messages| Puppet.info "Sending report to %s" % emails.join(", ") # We need to open a separate process for every set of email addresses - IO.popen(Puppet[:sendmail] + " " + emails.join(" "), "w") do |p| - p.puts "From: #{Puppet[:reportfrom]}" - p.puts "Subject: Puppet Report for %s" % self.host - p.puts "To: " + emails.join(", ") - - p.puts messages + sync.synchronize do + IO.popen(Puppet[:sendmail] + " " + emails.join(" "), "w") do |p| + p.puts "From: #{Puppet[:reportfrom]}" + p.puts "Subject: Puppet Report for %s" % self.host + p.puts "To: " + emails.join(", ") + + p.puts messages + end end end rescue => detail @@ -174,5 +176,11 @@ Puppet::Reports.register_report(:tagmail) do # Don't bother waiting for the pid to return. Process.detach(pid) end + + def sync + unless defined?(@sync) + @sync = Sync.new + end + end end |