thin 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of thin might be problematic. Click here for more details.
- data/CHANGELOG +11 -1
- data/COMMITTERS +3 -0
- data/README +4 -0
- data/Rakefile +2 -0
- data/ext/thin_parser/thin.c +9 -0
- data/lib/thin.rb +5 -5
- data/lib/thin/backends/base.rb +114 -0
- data/lib/thin/{connectors → backends}/swiftiply_client.rb +6 -6
- data/lib/thin/{connectors → backends}/tcp_server.rb +2 -2
- data/lib/thin/{connectors → backends}/unix_server.rb +19 -8
- data/lib/thin/connection.rb +3 -3
- data/lib/thin/controllers/controller.rb +6 -5
- data/lib/thin/controllers/service.rb +3 -1
- data/lib/thin/daemonizing.rb +20 -7
- data/lib/thin/logging.rb +1 -1
- data/lib/thin/request.rb +5 -5
- data/lib/thin/server.rb +63 -78
- data/lib/thin/version.rb +4 -2
- data/spec/{connectors → backends}/swiftiply_client_spec.rb +10 -10
- data/spec/{connectors → backends}/tcp_server_spec.rb +5 -5
- data/spec/backends/unix_server_spec.rb +37 -0
- data/spec/command_spec.rb +1 -0
- data/spec/connection_spec.rb +1 -1
- data/spec/controllers/controller_spec.rb +1 -0
- data/spec/daemonizing_spec.rb +31 -23
- data/spec/{request/perf_spec.rb → perf/request_perf_spec.rb} +0 -0
- data/spec/perf/response_perf_spec.rb +19 -0
- data/spec/perf/server_perf_spec.rb +39 -0
- data/spec/request/mongrel_spec.rb +1 -1
- data/spec/response_spec.rb +0 -11
- data/spec/runner_spec.rb +4 -4
- data/spec/server/builder_spec.rb +8 -3
- data/spec/server/pipelining_spec.rb +6 -5
- data/spec/server/swiftiply_spec.rb +25 -20
- data/spec/server/tcp_spec.rb +1 -9
- data/spec/server/unix_socket_spec.rb +1 -5
- data/spec/server_spec.rb +4 -7
- data/spec/spec_helper.rb +29 -5
- data/tasks/announce.rake +2 -2
- data/tasks/email.erb +13 -15
- data/tasks/ext.rake +28 -24
- data/tasks/gem.rake +13 -7
- data/tasks/spec.rake +14 -9
- metadata +23 -19
- data/lib/thin/connectors/connector.rb +0 -73
- data/spec/connectors/unix_server_spec.rb +0 -43
data/tasks/gem.rake
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'rake/gempackagetask'
|
2
2
|
|
3
|
+
WIN_SUFFIX = ENV['WIN_SUFFIX'] || 'x86-mswin32-60'
|
4
|
+
|
3
5
|
task :clean => :clobber_package
|
4
6
|
|
5
7
|
spec = Gem::Specification.new do |s|
|
@@ -11,17 +13,21 @@ spec = Gem::Specification.new do |s|
|
|
11
13
|
s.author = "Marc-Andre Cournoyer"
|
12
14
|
s.email = 'macournoyer@gmail.com'
|
13
15
|
s.homepage = 'http://code.macournoyer.com/thin/'
|
16
|
+
s.rubyforge_project = 'thin'
|
17
|
+
s.has_rdoc = true
|
14
18
|
s.executables = %w(thin)
|
15
19
|
|
16
|
-
s.required_ruby_version = '>= 1.8.
|
20
|
+
s.required_ruby_version = '>= 1.8.5'
|
17
21
|
|
18
22
|
s.add_dependency 'rack', '>= 0.2.0'
|
19
|
-
|
20
|
-
|
23
|
+
if WIN
|
24
|
+
s.add_dependency 'eventmachine', '>= 0.8.1'
|
25
|
+
else
|
21
26
|
s.add_dependency 'daemons', '>= 1.0.9'
|
27
|
+
s.add_dependency 'eventmachine', '>= 0.10.0' # TODO '>= 0.11.0' when it's released
|
22
28
|
end
|
23
29
|
|
24
|
-
s.files = %w(COPYING CHANGELOG README Rakefile) +
|
30
|
+
s.files = %w(COPYING CHANGELOG COMMITTERS README Rakefile) +
|
25
31
|
Dir.glob("{benchmark,bin,doc,example,lib,spec,tasks}/**/*") +
|
26
32
|
Dir.glob("ext/**/*.{h,c,rb,rl}")
|
27
33
|
|
@@ -63,7 +69,7 @@ namespace :gem do
|
|
63
69
|
namespace :upload do
|
64
70
|
desc 'Upload the precompiled win32 gem to code.macournoyer.com'
|
65
71
|
task :win do
|
66
|
-
upload "pkg/#{spec.full_name}
|
72
|
+
upload "pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem", 'gems'
|
67
73
|
system 'ssh macournoyer@macournoyer.com "cd code.macournoyer.com && gem generate_index"'
|
68
74
|
end
|
69
75
|
|
@@ -72,14 +78,14 @@ namespace :gem do
|
|
72
78
|
sh 'rubyforge login'
|
73
79
|
sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
|
74
80
|
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
|
75
|
-
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}
|
81
|
+
sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-#{WIN_SUFFIX}.gem"
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
79
85
|
desc 'Download the Windows gem from Kevin repo'
|
80
86
|
task 'download:win' => 'pkg' do
|
81
87
|
cd 'pkg' do
|
82
|
-
`wget http://rubygems.bantamtech.com/ruby18/gems/#{spec.full_name}
|
88
|
+
`wget http://rubygems.bantamtech.com/ruby18/gems/#{spec.full_name}-#{WIN_SUFFIX}.gem`
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|
data/tasks/spec.rake
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
CLEAN.include %w(coverage tmp log)
|
2
2
|
|
3
|
-
if RUBY_1_9
|
3
|
+
if RUBY_1_9 # RSpec not yet working w/ Ruby 1.9
|
4
4
|
task :spec do
|
5
5
|
warn 'RSpec not yet supporting Ruby 1.9, so cannot run the specs :('
|
6
6
|
end
|
7
7
|
else
|
8
|
-
# RSpec not yet working w/ Ruby 1.9
|
9
8
|
require 'spec/rake/spectask'
|
10
9
|
|
11
10
|
desc "Run all examples"
|
12
|
-
Spec::Rake::SpecTask.new(
|
13
|
-
t.
|
11
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
12
|
+
t.spec_opts = %w(-fs -c)
|
13
|
+
t.spec_files = FileList['spec/**/*_spec.rb'] - FileList['spec/perf/*_spec.rb']
|
14
14
|
if WIN
|
15
15
|
t.spec_files -= [
|
16
|
-
'spec/
|
16
|
+
'spec/backends/unix_server_spec.rb',
|
17
17
|
'spec/controllers/service_spec.rb',
|
18
18
|
'spec/daemonizing_spec.rb',
|
19
19
|
'spec/server/unix_socket_spec.rb',
|
@@ -21,15 +21,20 @@ else
|
|
21
21
|
]
|
22
22
|
end
|
23
23
|
end
|
24
|
+
task :spec => :compile
|
24
25
|
|
25
|
-
|
26
|
+
desc "Run all performance examples"
|
27
|
+
Spec::Rake::SpecTask.new('spec:perf') do |t|
|
28
|
+
t.spec_files = FileList['spec/perf/*_spec.rb']
|
29
|
+
end
|
30
|
+
|
31
|
+
task :check_benchmark_unit_gem do
|
26
32
|
begin
|
27
|
-
require 'spec'
|
28
33
|
require 'benchmark_unit'
|
29
34
|
rescue LoadError
|
30
|
-
abort "To run specs, install
|
35
|
+
abort "To run specs, install benchmark_unit gem"
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
34
|
-
task :
|
39
|
+
task 'spec:perf' => :check_benchmark_unit_gem
|
35
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-Andre Cournoyer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-03-06 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,22 +22,22 @@ dependencies:
|
|
22
22
|
version: 0.2.0
|
23
23
|
version:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
|
-
name:
|
25
|
+
name: daemons
|
26
26
|
version_requirement:
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: 0.
|
31
|
+
version: 1.0.9
|
32
32
|
version:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: eventmachine
|
35
35
|
version_requirement:
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.10.0
|
41
41
|
version:
|
42
42
|
description: A thin and fast web server
|
43
43
|
email: macournoyer@gmail.com
|
@@ -50,6 +50,7 @@ extra_rdoc_files: []
|
|
50
50
|
files:
|
51
51
|
- COPYING
|
52
52
|
- CHANGELOG
|
53
|
+
- COMMITTERS
|
53
54
|
- README
|
54
55
|
- Rakefile
|
55
56
|
- benchmark/abc
|
@@ -70,13 +71,13 @@ files:
|
|
70
71
|
- lib/rack/handler
|
71
72
|
- lib/rack/handler/thin.rb
|
72
73
|
- lib/thin
|
74
|
+
- lib/thin/backends
|
75
|
+
- lib/thin/backends/base.rb
|
76
|
+
- lib/thin/backends/swiftiply_client.rb
|
77
|
+
- lib/thin/backends/tcp_server.rb
|
78
|
+
- lib/thin/backends/unix_server.rb
|
73
79
|
- lib/thin/command.rb
|
74
80
|
- lib/thin/connection.rb
|
75
|
-
- lib/thin/connectors
|
76
|
-
- lib/thin/connectors/connector.rb
|
77
|
-
- lib/thin/connectors/swiftiply_client.rb
|
78
|
-
- lib/thin/connectors/tcp_server.rb
|
79
|
-
- lib/thin/connectors/unix_server.rb
|
80
81
|
- lib/thin/controllers
|
81
82
|
- lib/thin/controllers/cluster.rb
|
82
83
|
- lib/thin/controllers/controller.rb
|
@@ -94,15 +95,15 @@ files:
|
|
94
95
|
- lib/thin/statuses.rb
|
95
96
|
- lib/thin/version.rb
|
96
97
|
- lib/thin.rb
|
98
|
+
- spec/backends
|
99
|
+
- spec/backends/swiftiply_client_spec.rb
|
100
|
+
- spec/backends/tcp_server_spec.rb
|
101
|
+
- spec/backends/unix_server_spec.rb
|
97
102
|
- spec/command_spec.rb
|
98
103
|
- spec/configs
|
99
104
|
- spec/configs/cluster.yml
|
100
105
|
- spec/configs/single.yml
|
101
106
|
- spec/connection_spec.rb
|
102
|
-
- spec/connectors
|
103
|
-
- spec/connectors/swiftiply_client_spec.rb
|
104
|
-
- spec/connectors/tcp_server_spec.rb
|
105
|
-
- spec/connectors/unix_server_spec.rb
|
106
107
|
- spec/controllers
|
107
108
|
- spec/controllers/cluster_spec.rb
|
108
109
|
- spec/controllers/controller_spec.rb
|
@@ -110,6 +111,10 @@ files:
|
|
110
111
|
- spec/daemonizing_spec.rb
|
111
112
|
- spec/headers_spec.rb
|
112
113
|
- spec/logging_spec.rb
|
114
|
+
- spec/perf
|
115
|
+
- spec/perf/request_perf_spec.rb
|
116
|
+
- spec/perf/response_perf_spec.rb
|
117
|
+
- spec/perf/server_perf_spec.rb
|
113
118
|
- spec/rack_rails_spec.rb
|
114
119
|
- spec/rails_app
|
115
120
|
- spec/rails_app/app
|
@@ -173,7 +178,6 @@ files:
|
|
173
178
|
- spec/request
|
174
179
|
- spec/request/mongrel_spec.rb
|
175
180
|
- spec/request/parser_spec.rb
|
176
|
-
- spec/request/perf_spec.rb
|
177
181
|
- spec/request/persistent_spec.rb
|
178
182
|
- spec/request/processing_spec.rb
|
179
183
|
- spec/response_spec.rb
|
@@ -204,7 +208,7 @@ files:
|
|
204
208
|
- ext/thin_parser/extconf.rb
|
205
209
|
- ext/thin_parser/common.rl
|
206
210
|
- ext/thin_parser/parser.rl
|
207
|
-
has_rdoc:
|
211
|
+
has_rdoc: true
|
208
212
|
homepage: http://code.macournoyer.com/thin/
|
209
213
|
post_install_message:
|
210
214
|
rdoc_options: []
|
@@ -215,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
219
|
requirements:
|
216
220
|
- - ">="
|
217
221
|
- !ruby/object:Gem::Version
|
218
|
-
version: 1.8.
|
222
|
+
version: 1.8.5
|
219
223
|
version:
|
220
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
225
|
requirements:
|
@@ -225,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
229
|
version:
|
226
230
|
requirements: []
|
227
231
|
|
228
|
-
rubyforge_project:
|
232
|
+
rubyforge_project: thin
|
229
233
|
rubygems_version: 1.0.1
|
230
234
|
signing_key:
|
231
235
|
specification_version: 2
|
@@ -1,73 +0,0 @@
|
|
1
|
-
module Thin
|
2
|
-
module Connectors
|
3
|
-
# A Connector connect the server to the client. It handles:
|
4
|
-
# * connection/disconnection to the server
|
5
|
-
# * initialization of the connections
|
6
|
-
# * manitoring of the active connections.
|
7
|
-
class Connector
|
8
|
-
# Server serving the connections throught the connector
|
9
|
-
attr_accessor :server
|
10
|
-
|
11
|
-
# Maximum time for incoming data to arrive
|
12
|
-
attr_accessor :timeout
|
13
|
-
|
14
|
-
# Maximum number of connections that can be persistent
|
15
|
-
attr_accessor :maximum_persistent_connections
|
16
|
-
|
17
|
-
# Number of persistent connections currently opened
|
18
|
-
attr_accessor :persistent_connection_count
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
@connections = []
|
22
|
-
@timeout = Server::DEFAULT_TIMEOUT
|
23
|
-
@persistent_connection_count = 0
|
24
|
-
@maximum_persistent_connections = Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
|
25
|
-
end
|
26
|
-
|
27
|
-
# Free up resources used by the connector.
|
28
|
-
def close
|
29
|
-
end
|
30
|
-
|
31
|
-
def running?
|
32
|
-
@server.running?
|
33
|
-
end
|
34
|
-
|
35
|
-
# Initialize a new connection to a client.
|
36
|
-
def initialize_connection(connection)
|
37
|
-
connection.connector = self
|
38
|
-
connection.app = @server.app
|
39
|
-
connection.comm_inactivity_timeout = @timeout
|
40
|
-
|
41
|
-
# We control the number of persistent connections by keeping
|
42
|
-
# a count of the total one allowed yet.
|
43
|
-
if @persistent_connection_count < @maximum_persistent_connections
|
44
|
-
connection.can_persist!
|
45
|
-
@persistent_connection_count += 1
|
46
|
-
end
|
47
|
-
|
48
|
-
@connections << connection
|
49
|
-
end
|
50
|
-
|
51
|
-
# Close all active connections.
|
52
|
-
def close_connections
|
53
|
-
@connections.each { |connection| connection.close_connection }
|
54
|
-
end
|
55
|
-
|
56
|
-
# Called by a connection when it's unbinded.
|
57
|
-
def connection_finished(connection)
|
58
|
-
@persistent_connection_count -= 1 if connection.can_persist?
|
59
|
-
@connections.delete(connection)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Returns +true+ if no active connection.
|
63
|
-
def empty?
|
64
|
-
@connections.empty?
|
65
|
-
end
|
66
|
-
|
67
|
-
# Number of active connections.
|
68
|
-
def size
|
69
|
-
@connections.size
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Connectors::UnixServer do
|
4
|
-
before do
|
5
|
-
@connector = Connectors::UnixServer.new('/tmp/thin-test.sock')
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should connect" do
|
9
|
-
EventMachine.run do
|
10
|
-
@connector.connect
|
11
|
-
EventMachine.stop
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should disconnect" do
|
16
|
-
EventMachine.run do
|
17
|
-
@connector.connect
|
18
|
-
@connector.disconnect
|
19
|
-
EventMachine.stop
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should remove socket file on close" do
|
24
|
-
@connector.close
|
25
|
-
File.exist?('/tmp/thin-test.sock').should be_false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe UnixConnection do
|
30
|
-
before do
|
31
|
-
@connection = UnixConnection.new(nil)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return nil on error retreiving remote_address" do
|
35
|
-
@connection.stub!(:get_peername).and_raise(RuntimeError)
|
36
|
-
@connection.remote_address.should be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should return remote_address" do
|
40
|
-
@connection.stub!(:get_peername).and_return("\000\001127.0.0.1\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")
|
41
|
-
@connection.remote_address.should == '127.0.0.1'
|
42
|
-
end
|
43
|
-
end
|