* 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
Родитель a90c99ee0c
Коммит 8594cab140
2 изменённых файлов: 10 добавлений и 8 удалений

Просмотреть файл

@ -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