1
0
Fork 0
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:
sonots 2015-11-20 14:16:56 +00:00
parent a90c99ee0c
commit 8594cab140
2 changed files with 10 additions and 8 deletions

View file

@ -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> Fri Nov 20 15:05:28 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* Added missing reference of GitHub * Added missing reference of GitHub

View file

@ -626,14 +626,11 @@ private
attr_reader :dev attr_reader :dev
attr_reader :filename attr_reader :filename
include MonitorMixin
class LogDeviceMutex
include MonitorMixin
end
def initialize(log = nil, opt = {}) def initialize(log = nil, opt = {})
@dev = @filename = @shift_age = @shift_size = nil @dev = @filename = @shift_age = @shift_size = nil
@mutex = LogDeviceMutex.new mon_initialize
set_dev(log) set_dev(log)
if @filename if @filename
@shift_age = opt[:shift_age] || 7 @shift_age = opt[:shift_age] || 7
@ -644,7 +641,7 @@ private
def write(message) def write(message)
begin begin
@mutex.synchronize do synchronize do
if @shift_age and @dev.respond_to?(:stat) if @shift_age and @dev.respond_to?(:stat)
begin begin
check_shift_log check_shift_log
@ -665,7 +662,7 @@ private
def close def close
begin begin
@mutex.synchronize do synchronize do
@dev.close rescue nil @dev.close rescue nil
end end
rescue Exception rescue Exception
@ -677,7 +674,7 @@ private
# reopen the same filename if no argument, do nothing for IO # reopen the same filename if no argument, do nothing for IO
log ||= @filename if @filename log ||= @filename if @filename
if log if log
@mutex.synchronize do synchronize do
if @filename and @dev if @filename and @dev
@dev.close rescue nil # close only file opened by Logger @dev.close rescue nil # close only file opened by Logger
@filename = nil @filename = nil