diff --git a/ChangeLog b/ChangeLog index 90b56804df..cece151162 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun May 17 17:21:29 2015 Eric Wong + + * lib/webrick/utils.rb (set_non_blocking): use IO#nonblock= + * (set_close_on_exec): use IO#close_on_exec= + [Feature #11136] + Sun May 17 15:01:26 2015 Nobuyoshi Nakada * numeric.c (num_positive_p, num_negative_p): add methods diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb index 5be4db8c0d..bde3d01ca5 100644 --- a/lib/webrick/utils.rb +++ b/lib/webrick/utils.rb @@ -9,7 +9,7 @@ # $IPR: utils.rb,v 1.10 2003/02/16 22:22:54 gotoyuzo Exp $ require 'socket' -require 'fcntl' +require 'io/nonblock' require 'etc' module WEBrick @@ -17,20 +17,14 @@ module WEBrick ## # Sets IO operations on +io+ to be non-blocking def set_non_blocking(io) - flag = File::NONBLOCK - if defined?(Fcntl::F_GETFL) - flag |= io.fcntl(Fcntl::F_GETFL) - end - io.fcntl(Fcntl::F_SETFL, flag) + io.nonblock = true if io.respond_to?(:nonblock=) end module_function :set_non_blocking ## # Sets the close on exec flag for +io+ def set_close_on_exec(io) - if defined?(Fcntl::FD_CLOEXEC) - io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - end + io.close_on_exec = true if io.respond_to?(:close_on_exec=) end module_function :set_close_on_exec