diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-11-10 13:44:44 -0500 |
---|---|---|
committer | Vladimir Kochnev <hashtable@yandex.ru> | 2017-04-18 00:34:42 +0300 |
commit | aa9f82fcf2a5a1586f74b0afa58ffb0bfc0cd1cb (patch) | |
tree | e663e96b77533297644f54792b8b5e59c5077511 | |
parent | 1886a60e9b96c2a4106fd89eb41dc817696c6369 (diff) | |
download | rack-aa9f82fcf2a5a1586f74b0afa58ffb0bfc0cd1cb.tar.gz |
Merge pull request #1080 from sophiedeziel/master
Prevent exception caused by a race condition on multi-threaded servers
-rw-r--r-- | lib/rack/server.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/rack/server.rb b/lib/rack/server.rb index 2253b314..2d36eb6d 100644 --- a/lib/rack/server.rb +++ b/lib/rack/server.rb @@ -1,4 +1,5 @@ require 'optparse' +require 'fileutils' module Rack @@ -352,7 +353,7 @@ module Rack def write_pid ::File.open(options[:pid], ::File::CREAT | ::File::EXCL | ::File::WRONLY ){ |f| f.write("#{Process.pid}") } - at_exit { ::File.delete(options[:pid]) if ::File.exist?(options[:pid]) } + at_exit { ::FileUtils.rm_f(options[:pid]) } rescue Errno::EEXIST check_pid! retry |