rainbows-emtp 0.5.1 → 0.5.2

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: a056ee3bba9e84ff779f854c5d3ca760ae64d29f
4
- data.tar.gz: f53e6b8a43b906078fcc0df11016c44a5c594bfc
3
+ metadata.gz: 12ec1b107844d2d9afdebb13afb37a108215539e
4
+ data.tar.gz: cdbb172e772e976a83b519d2d8ec5c95d1a6c36b
5
5
  SHA512:
6
- metadata.gz: 1ab106d2da425d72b1dfb9d15b0f4ccfb11df32dc53cdce48e6e4dc75b623031b7e7843262cbc6ba0c86938764c227de517ab954e7911d01186de08393e1c66d
7
- data.tar.gz: d9a022f75d25a4711a4be24fec12a5f37df50ba6a9b0d33d49f0b307f333cf0200d9130f7f7eac6772db695b730ef7722d892d531e77ecf0dce2683528ee03ee
6
+ metadata.gz: 49e438d29dc3b33908232e97ef1873205210cbd84966289de085ac06ff37c943ba5c8baa0c9125058bf8e5709b85f56842764d90532e58f1c682c3ed47b2a369
7
+ data.tar.gz: 3614bba3b18a6fd41b6226f82b79ed37ccad5e6b0eba80a1a1e0308cf2538cf55d3571982220f0e3529a99bc6311560adbe00be1e195212a7a442679395daac6
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ desc 'Generate gemspec'
8
8
  task 'gem:spec' do
9
9
  Gemgem.spec = Gemgem.create do |s|
10
10
  s.name = 'rainbows-emtp'
11
- s.version = '0.5.1'
11
+ s.version = '0.5.2'
12
12
 
13
13
  %w[rainbows eventmachine].each{ |g| s.add_runtime_dependency(g) }
14
14
  end
@@ -1,3 +1,4 @@
1
+ # -*- encoding: binary -*-
1
2
 
2
3
  require 'rainbows'
3
4
 
@@ -6,8 +7,9 @@ module Rainbows::EventMachineThreadPool
6
7
  extend Rainbows::PoolSize
7
8
  include Rainbows::EventMachine
8
9
 
9
- def init_worker_process worker
10
+ def init_worker_process(worker)
10
11
  EM.threadpool_size = Rainbows::O[:pool_size]
12
+ logger.info "EventMachineThreadPool pool_size=#{Rainbows::O[:pool_size]}"
11
13
  super
12
14
  end
13
15
  end
@@ -1,44 +1,47 @@
1
-
2
- require 'rainbows/event_machine_thread_pool'
3
-
1
+ # -*- encoding: binary -*-
2
+ # :enddoc:
4
3
  class Rainbows::EventMachineThreadPool::Client <
5
4
  Rainbows::EventMachine::Client
6
5
 
6
+ def app_dispatch
7
+ EM.defer(method(:app_response), method(:response_write))
8
+ end
9
+
7
10
  def app_call input
8
- # begin Copied from Rainbows::EventMachine::Client#app_call
11
+ @deferred = true # we defer immediately
9
12
  set_comm_inactivity_timeout 0
10
13
  @env[RACK_INPUT] = input
11
14
  @env[REMOTE_ADDR] = @_io.kgio_addr
12
15
  @env[ASYNC_CALLBACK] = method(:write_async_response)
13
16
  @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new
14
17
  @hp.hijack_setup(@env, @_io)
15
- # end Copied from Rainbows::EventMachine::Client#app_call
18
+ app_dispatch # must be implemented by subclass
19
+ end
16
20
 
17
- @deferred = true # We defer immediately
18
- EM.defer do # Queue the application call to EM's job queue
19
- begin
20
- status, headers, body = catch(:async) {
21
- APP.call(@env.merge!(RACK_DEFAULTS))
22
- }
23
- if @hp.hijacked?
24
- @deferred = nil # User must handle everything by themselves
25
- hijacked
26
- elsif nil == status || -1 == status
27
- @deferred = true
28
- else
29
- @deferred = nil
30
- ev_write_response(status, headers, body, @hp.next?)
31
- end
32
- # Never ever crash any thread
33
- rescue Exception => e
34
- begin # Any user codes should be guarded
35
- if handler = EM.instance_variable_get(:@error_handler)
36
- handler.call(e)
37
- end
38
- rescue Exception
39
- end
40
- handle_error(e)
41
- end
21
+ # this is only called in the master thread
22
+ def response_write(response)
23
+ if @hp.hijacked?
24
+ @deferred = nil
25
+ hijacked
26
+ elsif nil == response[0] || -1 == response[0]
27
+ @deferred = true
28
+ else
29
+ @deferred = nil
30
+ ev_write_response(*response, @hp.next?)
42
31
  end
32
+ rescue => e
33
+ @deferred = nil
34
+ handle_error(e)
35
+ end
36
+
37
+ # fails-safe application dispatch, we absolutely cannot
38
+ # afford to fail or raise an exception (killing the thread)
39
+ # here because that could cause a deadlock and we'd leak FDs
40
+ def app_response
41
+ APP.call(@env.merge!(RACK_DEFAULTS))
42
+ rescue => e
43
+ Rainbows::Error.app(e) # we guarantee this does not raise
44
+ [ 500, {}, [] ]
43
45
  end
46
+
44
47
  end
@@ -1,12 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: rainbows-emtp 0.5.2 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "rainbows-emtp"
5
- s.version = "0.5.1"
6
+ s.version = "0.5.2"
6
7
 
7
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
9
  s.authors = ["Lin Jen-Shin (godfat)"]
9
- s.date = "2013-08-24"
10
+ s.date = "2013-09-17"
10
11
  s.description = "EventMachineThreadPool model for Rainbows!"
11
12
  s.email = ["godfat (XD) godfat.org"]
12
13
  s.files = [
@@ -25,7 +26,7 @@ Gem::Specification.new do |s|
25
26
  s.homepage = "https://github.com/godfat/rainbows-emtp"
26
27
  s.licenses = ["Apache License 2.0"]
27
28
  s.require_paths = ["lib"]
28
- s.rubygems_version = "2.0.6"
29
+ s.rubygems_version = "2.1.3"
29
30
  s.summary = "EventMachineThreadPool model for Rainbows!"
30
31
 
31
32
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rainbows-emtp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-24 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbows
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.6
80
+ rubygems_version: 2.1.3
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: EventMachineThreadPool model for Rainbows!