thin-fun_embed 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/thin/fun_daemon.rb +13 -8
- data/lib/thin/fun_embed.rb +6 -1
- data/lib/thin/fun_embed/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 512fa7b71408f95661f0b1a58d691e776aca685d
|
4
|
+
data.tar.gz: 99743032ffaac47bf15a9e4e5d9e545f9e216d8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7936654dad4567515ef60ff16b364edff7c3ede8843ae3e86f36f3418b9d7c6e2c9b00b6f2be07c6f14ee728ea98d7aac742e74f8a732445b824f5f406a46e5e
|
7
|
+
data.tar.gz: b73a4cb64bf6b9d6d4a596b22d9b34abcaa9b85b57e9fca953351be83bc7d87b636572b092c5b0848982d73f7862994e3f9773b7684c07a0efdf55870cf682a0
|
data/lib/thin/fun_daemon.rb
CHANGED
@@ -21,12 +21,13 @@ module Thin
|
|
21
21
|
def self.trap
|
22
22
|
return if @trap_set
|
23
23
|
@trap_set = true
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
@prev_traps = {}
|
25
|
+
[:INT, :TERM, :QUIT].each do |name|
|
26
|
+
@prev_traps[name] = ::Signal.trap(name){|sig| trap_call(name, sig) }
|
27
|
+
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def self.trap_call
|
30
|
+
def self.trap_call(name, sig)
|
30
31
|
@trap_called = true
|
31
32
|
Thread.new do
|
32
33
|
EM.schedule do
|
@@ -35,16 +36,20 @@ module Thin
|
|
35
36
|
end
|
36
37
|
if @conns && !@conns.empty?
|
37
38
|
@conns.each do |conn, _|
|
38
|
-
conn.
|
39
|
+
conn.force_close!
|
39
40
|
end
|
40
41
|
else
|
41
42
|
EM.next_tick{ EM.stop }
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
@prev_traps.each do |nm, prev|
|
47
|
+
if nm == name && prev.respond_to?(:call)
|
48
|
+
prev.call(sig)
|
49
|
+
next
|
50
|
+
end
|
51
|
+
::Signal.trap(nm, prev)
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
def self.run_class(host, port, klass, *args, &block)
|
data/lib/thin/fun_embed.rb
CHANGED
@@ -60,6 +60,7 @@ module Thin # :nodoc:
|
|
60
60
|
|
61
61
|
def post_init
|
62
62
|
@keep_alive = nil
|
63
|
+
@force_close = false
|
63
64
|
@parser = Thin::Request.new
|
64
65
|
end
|
65
66
|
|
@@ -166,7 +167,7 @@ module Thin # :nodoc:
|
|
166
167
|
# call this when you fully send response
|
167
168
|
def consider_keep_alive(try_keep_alive = true)
|
168
169
|
@parser.close rescue nil
|
169
|
-
if @keep_alive && try_keep_alive
|
170
|
+
if @keep_alive && try_keep_alive && !@force_close
|
170
171
|
post_init
|
171
172
|
else
|
172
173
|
close_connection_after_writing
|
@@ -176,6 +177,10 @@ module Thin # :nodoc:
|
|
176
177
|
def unbind # :nodoc:
|
177
178
|
@unbind_callback && @unbind_callback.call(self)
|
178
179
|
end
|
180
|
+
|
181
|
+
def force_close!
|
182
|
+
@force_close = true
|
183
|
+
end
|
179
184
|
end
|
180
185
|
|
181
186
|
class FunRackLike < FunEmbed
|