mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/logger.rb: expose logger mutex
[fix GH-541] Patch by @arthurnn git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									a90c99ee0c
								
							
						
					
					
						commit
						8594cab140
					
				
					 2 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,8 @@
 | 
			
		|||
Fri Nov 20 23:15:18 2015  Naotoshi Seo  <sonots@gmail.com>
 | 
			
		||||
 | 
			
		||||
	* lib/logger.rb: expose logger mutex
 | 
			
		||||
	  [fix GH-541] Patch by @arthurnn
 | 
			
		||||
 | 
			
		||||
Fri Nov 20 15:05:28 2015  SHIBATA Hiroshi  <hsbt@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* Added missing reference of GitHub
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -626,14 +626,11 @@ private
 | 
			
		|||
 | 
			
		||||
    attr_reader :dev
 | 
			
		||||
    attr_reader :filename
 | 
			
		||||
 | 
			
		||||
    class LogDeviceMutex
 | 
			
		||||
    include MonitorMixin
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def initialize(log = nil, opt = {})
 | 
			
		||||
      @dev = @filename = @shift_age = @shift_size = nil
 | 
			
		||||
      @mutex = LogDeviceMutex.new
 | 
			
		||||
      mon_initialize
 | 
			
		||||
      set_dev(log)
 | 
			
		||||
      if @filename
 | 
			
		||||
        @shift_age = opt[:shift_age] || 7
 | 
			
		||||
| 
						 | 
				
			
			@ -644,7 +641,7 @@ private
 | 
			
		|||
 | 
			
		||||
    def write(message)
 | 
			
		||||
      begin
 | 
			
		||||
        @mutex.synchronize do
 | 
			
		||||
        synchronize do
 | 
			
		||||
          if @shift_age and @dev.respond_to?(:stat)
 | 
			
		||||
            begin
 | 
			
		||||
              check_shift_log
 | 
			
		||||
| 
						 | 
				
			
			@ -665,7 +662,7 @@ private
 | 
			
		|||
 | 
			
		||||
    def close
 | 
			
		||||
      begin
 | 
			
		||||
        @mutex.synchronize do
 | 
			
		||||
        synchronize do
 | 
			
		||||
          @dev.close rescue nil
 | 
			
		||||
        end
 | 
			
		||||
      rescue Exception
 | 
			
		||||
| 
						 | 
				
			
			@ -677,7 +674,7 @@ private
 | 
			
		|||
      # reopen the same filename if no argument, do nothing for IO
 | 
			
		||||
      log ||= @filename if @filename
 | 
			
		||||
      if log
 | 
			
		||||
        @mutex.synchronize do
 | 
			
		||||
        synchronize do
 | 
			
		||||
          if @filename and @dev
 | 
			
		||||
            @dev.close rescue nil # close only file opened by Logger
 | 
			
		||||
            @filename = nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue