diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-04-19 19:53:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 19:53:23 -0400 |
commit | 2e6313c292ca8ac8e2459bc35185aac5a0e0a228 (patch) | |
tree | e663e96b77533297644f54792b8b5e59c5077511 | |
parent | 1886a60e9b96c2a4106fd89eb41dc817696c6369 (diff) | |
parent | aa9f82fcf2a5a1586f74b0afa58ffb0bfc0cd1cb (diff) | |
download | rack-2e6313c292ca8ac8e2459bc35185aac5a0e0a228.tar.gz |
Merge pull request #1158 from marshall-lee/1-6-stable-backport-2f8b710
Backport to 1.6: prevent exception caused by a race condition on multi-threaded server like Puma.
-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 |