Skip to content
Browse files

make read_rules multithread save

  • Loading branch information...
1 parent 98cfc1a commit 1afe79dc3fe43e2790bfbad596c34caf849e335d @bledig committed Mar 10, 2015
Showing with 9 additions and 4 deletions.
  1. +8 −3 lib/tuersteher.rb
  2. +1 −1 tuersteher.gemspec
View
11 lib/tuersteher.rb
@@ -8,6 +8,7 @@
require 'singleton'
require 'logger'
+require 'thread'
module Tuersteher
@@ -46,6 +47,7 @@ def initialize
@path_rules = []
@model_rules = []
@check_intervall = 300 # set default check interval to 5 minutes
+ @mutex = Mutex.new
end
def ready?
@@ -103,9 +105,12 @@ def eval_rules rules_definitions
# config/access_rules.rb
def read_rules
@was_read = false
- content = File.read self.rules_config_file
- if content
- eval_rules content
+ @mutex.synchronize do
+ return if @was_read # dann hat ein anderer Thread bereits gelesen
+ content = File.read self.rules_config_file
+ if content
+ eval_rules content
+ end
end
rescue => ex
Tuersteher::TLogger.logger.error "Tuersteher::AccessRulesStorage - Error in rules: #{ex.message}\n\t"+ex.backtrace.join("\n\t")
View
2 tuersteher.gemspec
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = 'tuersteher'
- s.version = '0.7.1'
+ s.version = '0.7.2'
s.authors = ["Bernd Ledig"]
s.email = ["bernd@ledig.info"]
s.homepage = "http://github.com/bledig/tuersteher"

0 comments on commit 1afe79d

Please sign in to comment.
Something went wrong with that request. Please try again.