pitchfork 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pitchfork might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/pitchfork/http_server.rb +11 -3
- data/lib/pitchfork/version.rb +1 -1
- data/lib/pitchfork.rb +35 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37584c7333941059ab10086a74d1102b1969c2fefb7a759fc13f9e4f837891e
|
4
|
+
data.tar.gz: bc69759f0a53d98d81648ee60b833e6c49fd3f88d53f7ac319e9acff845c7cf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69d796bf414bb4bf7b7867e61229fa12764ca12dd1aaf2b36a615c2b806a64aa665b4c1483147e6d39a4d49df340ad31406f0db294da52e9a8a5740b186233a9
|
7
|
+
data.tar.gz: 51dc5852d5bc26fbba0f1824beb76977653ae089d589e33a1d7defca89b9b2235f466c5fc59419f56d0944b6c5ee819e1f966e9c32eac3d79029d951a6071c38
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -606,7 +606,10 @@ module Pitchfork
|
|
606
606
|
end
|
607
607
|
|
608
608
|
unless client.closed? # rack.hijack may've close this for us
|
609
|
-
|
609
|
+
begin
|
610
|
+
client.shutdown # in case of fork() in Rack app
|
611
|
+
rescue Errno::ENOTCONN
|
612
|
+
end
|
610
613
|
client.close # flush and uncork socket immediately, no keepalive
|
611
614
|
end
|
612
615
|
rescue => e
|
@@ -730,10 +733,15 @@ module Pitchfork
|
|
730
733
|
mold.start_promotion(@control_socket[1])
|
731
734
|
mold_loop(mold)
|
732
735
|
end
|
733
|
-
|
734
|
-
|
736
|
+
rescue
|
737
|
+
# HACK: we need to call this on error or on no error, but not on throw
|
738
|
+
# hence why we don't use `ensure`
|
739
|
+
@promotion_lock.at_fork
|
740
|
+
raise
|
741
|
+
else
|
735
742
|
@promotion_lock.at_fork # We let the spawned mold own the lock
|
736
743
|
end
|
744
|
+
true
|
737
745
|
end
|
738
746
|
|
739
747
|
def mold_loop(mold)
|
data/lib/pitchfork/version.rb
CHANGED
data/lib/pitchfork.rb
CHANGED
@@ -121,21 +121,42 @@ module Pitchfork
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def self.clean_fork(&block)
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
#
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
124
|
+
if pid = Process.fork
|
125
|
+
return pid
|
126
|
+
end
|
127
|
+
|
128
|
+
begin
|
129
|
+
# Pitchfork recursively refork the worker processes.
|
130
|
+
# Because of this we need to unwind the stack before resuming execution
|
131
|
+
# in the child, otherwise on each generation the available stack space would
|
132
|
+
# get smaller and smaller until it's basically 0.
|
133
|
+
#
|
134
|
+
# The very first version of this method used to call fork from a new
|
135
|
+
# thread, however this can cause issues with some native gems that rely on
|
136
|
+
# pthread_atfork(3) or pthread_mutex_lock(3), as the new main thread would
|
137
|
+
# now be different.
|
138
|
+
#
|
139
|
+
# A second version used to fork from a new fiber, but fibers have a much smaller
|
140
|
+
# stack space (https://bugs.ruby-lang.org/issues/3187), so it would break large applications.
|
141
|
+
#
|
142
|
+
# The latest version now use `throw` to unwind the stack after the fork, it however
|
143
|
+
# restrict it to be called only inside `handle_clean_fork`.
|
144
|
+
if Thread.current[:pitchfork_handle_clean_fork]
|
145
|
+
throw self, block
|
146
|
+
else
|
147
|
+
while block
|
148
|
+
block = catch(self) do
|
149
|
+
Thread.current[:pitchfork_handle_clean_fork] = true
|
150
|
+
block.call
|
151
|
+
nil
|
152
|
+
end
|
153
|
+
end
|
136
154
|
end
|
137
|
-
|
138
|
-
|
155
|
+
rescue
|
156
|
+
abort
|
157
|
+
else
|
158
|
+
exit
|
159
|
+
end
|
139
160
|
end
|
140
161
|
|
141
162
|
def self.fork_sibling(&block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pitchfork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raindrops
|