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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 554cca8c4ae41336cb638483d6435f7e6b890c39
4
- data.tar.gz: 6b247bd9fbc43b05020e5b18f0bcde245c993d2e
3
+ metadata.gz: 512fa7b71408f95661f0b1a58d691e776aca685d
4
+ data.tar.gz: 99743032ffaac47bf15a9e4e5d9e545f9e216d8e
5
5
  SHA512:
6
- metadata.gz: f8b61923ba35ee4012c285462a7dc05c46ce5c5c09468a01e72dcccc6aae54ecbc1c6e1de2e01ee8bac0d8386e6a43df1f37cd2f3d8f769f459c5a1001bdd501
7
- data.tar.gz: 8fb9978fcf053c339bf15d7aae8f8b99c9ce72ad2b96cd9ec8c7c637feb3e3a5f30ad67217c6780c3e334a091fd3bae0214d73642d6eef2d695a819bbd4fb419
6
+ metadata.gz: 7936654dad4567515ef60ff16b364edff7c3ede8843ae3e86f36f3418b9d7c6e2c9b00b6f2be07c6f14ee728ea98d7aac742e74f8a732445b824f5f406a46e5e
7
+ data.tar.gz: b73a4cb64bf6b9d6d4a596b22d9b34abcaa9b85b57e9fca953351be83bc7d87b636572b092c5b0848982d73f7862994e3f9773b7684c07a0efdf55870cf682a0
@@ -21,12 +21,13 @@ module Thin
21
21
  def self.trap
22
22
  return if @trap_set
23
23
  @trap_set = true
24
- ::Signal.trap(:INT){ trap_call }
25
- ::Signal.trap(:TERM){ trap_call }
26
- ::Signal.trap(:QUIT){ trap_call }
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.close_connection_after_writing
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
- ::Signal.trap(:INT, 'DEFAULT')
46
- ::Signal.trap(:TERM, 'DEFAULT')
47
- ::Signal.trap(:QUIT, 'DEFAULT')
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)
@@ -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
@@ -1,6 +1,6 @@
1
1
  require 'eventmachine'
2
2
  module Thin # :nodoc:
3
3
  class FunEmbed < EM::Connection
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin-fun_embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sokolov Yura 'funny-falcon'