[前][次][番号順一覧][スレッド一覧]

ruby-changes:71028

From: Jesse <ko1@a...>
Date: Thu, 27 Jan 2022 12:33:23 +0900 (JST)
Subject: [ruby-changes:71028] 99d02caed3 (master): [ruby/logger] Fix log rotation inter-process lock failed.

https://git.ruby-lang.org/ruby.git/commit/?id=99d02caed3

From 99d02caed3fb86a8bbe3ae6daddf2517e2f3f441 Mon Sep 17 00:00:00 2001
From: Jesse Chavez <jesse.chavez.r@g...>
Date: Wed, 26 Jan 2022 14:05:21 -0500
Subject: [ruby/logger] Fix log rotation inter-process lock failed.

Issue only occurs in JRuby 9.3.0.0 and Windows and the full
console output is:

log rotation inter-process lock failed. D:\log.txt -> D:\log.txt.0: The process cannot access the file because it is being used by another process.
log writing failed. closed stream
log writing failed. closed stream
...

https://github.com/ruby/logger/commit/19fc734638
---
 lib/logger.rb                 | 1 +
 lib/logger/log_device.rb      | 2 +-
 test/logger/test_logdevice.rb | 3 ++-
 tool/lib/core_assertions.rb   | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/logger.rb b/lib/logger.rb
index 4205380a6ac..7d55f62f301 100644
--- a/lib/logger.rb
+++ b/lib/logger.rb
@@ -11,6 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L11
 # A simple system for logging messages.  See Logger for more documentation.
 
 require 'monitor'
+require 'rbconfig'
 
 require_relative 'logger/version'
 require_relative 'logger/formatter'
diff --git a/lib/logger/log_device.rb b/lib/logger/log_device.rb
index 96d77b7b6ad..8683328a5e2 100644
--- a/lib/logger/log_device.rb
+++ b/lib/logger/log_device.rb
@@ -135,7 +135,7 @@ class Logger https://github.com/ruby/ruby/blob/trunk/lib/logger/log_device.rb#L135
       end
     end
 
-    if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
+    if /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
       def lock_shift_log
         yield
       end
diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb
index d360fa2107d..8f1c15542ab 100644
--- a/test/logger/test_logdevice.rb
+++ b/test/logger/test_logdevice.rb
@@ -435,6 +435,7 @@ class TestLogDevice < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/logger/test_logdevice.rb#L435
 
         logdev1.write(message)
         assert_file.identical?(log, logdev1.dev)
+        # NOTE: below assertion fails in JRuby 9.3 and TruffleRuby
         assert_file.identical?(log + ".0", logdev2.dev)
 
         logdev2.write(message)
@@ -451,7 +452,7 @@ class TestLogDevice < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/logger/test_logdevice.rb#L452
     end
   ensure
     logdev0.close
-  end unless /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
+  end unless /mswin|mingw|cygwin/ =~ RbConfig::CONFIG['host_os']
 
   def test_shifting_midnight
     Dir.mktmpdir do |tmpdir|
diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb
index 51cb7ebf0dd..e9c586f9102 100644
--- a/tool/lib/core_assertions.rb
+++ b/tool/lib/core_assertions.rb
@@ -254,7 +254,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/core_assertions.rb#L254
           line ||= loc.lineno
         end
         capture_stdout = true
-        unless /mswin|mingw/ =~ RUBY_PLATFORM
+        unless /mswin|mingw/ =~ RbConfig::CONFIG['host_os']
           capture_stdout = false
           opt[:out] = Test::Unit::Runner.output if defined?(Test::Unit::Runner)
           res_p, res_c = IO.pipe
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]