don't set listen(2) backlog on inherited sockets
[yahns.git] / examples / logger_mp_safe.rb
blob569d6613d7aef05b0844316a00a2a18689c56c45
1 # To the extent possible under law, Eric Wong has waived all copyright and
2 # related or neighboring rights to this examples
4 # Multi-Processing-safe monkey patch for Logger
6 # This monkey patch fixes the case where "preload: true" is used and
7 # the application spawns a background thread upon being loaded.
9 # This removes all lock from the Logger code and solely relies on the
10 # underlying filesystem to handle write(2) system calls atomically when
11 # O_APPEND is used.  This is safe in the presence of both multiple
12 # threads (native or green) and multiple processes when writing to
13 # a filesystem with POSIX O_APPEND semantics.
15 # It should be noted that the original locking on Logger could _never_ be
16 # considered reliable on non-POSIX filesystems with multiple processes,
17 # either, so nothing is lost in that case.
19 require 'logger'
20 class Logger::LogDevice
21   def write(message)
22     @dev.syswrite(message)
23   end
25   def close
26     @dev.close
27   end
28 end