public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Rename Connector to Backend. Extend Thin::Backends::Base to implement your 
own.
macournoyer (author)
Thu Feb 28 18:23:39 -0800 2008
commit  b686394e285dd2e188aa990bafc94d31a12ed92f
tree    e3a26d921d2e672f41ed49031e83739d94c0cb84
parent  659446428f3dc609addbe940b26eb0d5638577e6
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 == 0.7.1 Fancy Pants release
0
+ * Rename Connector to Backend. Extend Thin::Backends::Base to implement your own.
0
  * Fix high memory usage with big POST body, fixes #48
0
 
0
 == 0.7.0 Spherical Cow release
...
22
23
24
25
26
27
28
29
 
 
 
 
 
30
31
32
...
22
23
24
 
 
 
 
 
25
26
27
28
29
30
31
32
0
@@ -22,11 +22,11 @@
0
   autoload :Server, 'thin/server'
0
   autoload :Stats, 'thin/stats'
0
   
0
- module Connectors
0
- autoload :Connector, 'thin/connectors/connector'
0
- autoload :SwiftiplyClient, 'thin/connectors/swiftiply_client'
0
- autoload :TcpServer, 'thin/connectors/tcp_server'
0
- autoload :UnixServer, 'thin/connectors/unix_server'
0
+ module Backends
0
+ autoload :Base, 'thin/backends/base'
0
+ autoload :SwiftiplyClient, 'thin/backends/swiftiply_client'
0
+ autoload :TcpServer, 'thin/backends/tcp_server'
0
+ autoload :UnixServer, 'thin/backends/unix_server'
0
   end
0
   
0
   module Controllers
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
0
@@ -1 +1,74 @@
0
+module Thin
0
+ module Backends
0
+ # A Backend connects the server to the client. It handles:
0
+ # * connection/disconnection to the server
0
+ # * initialization of the connections
0
+ # * manitoring of the active connections.
0
+ class Base
0
+ # Server serving the connections throught the backend
0
+ attr_accessor :server
0
+
0
+ # Maximum time for incoming data to arrive
0
+ attr_accessor :timeout
0
+
0
+ # Maximum number of connections that can be persistent
0
+ attr_accessor :maximum_persistent_connections
0
+
0
+ # Number of persistent connections currently opened
0
+ attr_accessor :persistent_connection_count
0
+
0
+ def initialize
0
+ @connections = []
0
+ @timeout = Server::DEFAULT_TIMEOUT
0
+ @persistent_connection_count = 0
0
+ @maximum_persistent_connections = Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
0
+ end
0
+
0
+ # Free up resources used by the backend.
0
+ def close
0
+ end
0
+
0
+ def running?
0
+ @server.running?
0
+ end
0
+
0
+ # Initialize a new connection to a client.
0
+ def initialize_connection(connection)
0
+ connection.backend = self
0
+ connection.app = @server.app
0
+ connection.comm_inactivity_timeout = @timeout
0
+
0
+ # We control the number of persistent connections by keeping
0
+ # a count of the total one allowed yet.
0
+ if @persistent_connection_count < @maximum_persistent_connections
0
+ connection.can_persist!
0
+ @persistent_connection_count += 1
0
+ end
0
+
0
+ @connections << connection
0
+ end
0
+
0
+ # Close all active connections.
0
+ def close_connections
0
+ @connections.each { |connection| connection.close_connection }
0
+ end
0
+
0
+ # Called by a connection when it's unbinded.
0
+ def connection_finished(connection)
0
+ @persistent_connection_count -= 1 if connection.can_persist?
0
+ @connections.delete(connection)
0
+ end
0
+
0
+ # Returns +true+ if no active connection.
0
+ def empty?
0
+ @connections.empty?
0
+ end
0
+
0
+ # Number of active connections.
0
+ def size
0
+ @connections.size
0
+ end
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -1 +1,56 @@
0
+module Thin
0
+ module Backends
0
+ class SwiftiplyClient < Base
0
+ attr_accessor :key
0
+
0
+ attr_accessor :host, :port
0
+
0
+ def initialize(host, port, key=nil)
0
+ @host = host
0
+ @port = port.to_i
0
+ @key = key || ''
0
+ super()
0
+ end
0
+
0
+ # Connect the server
0
+ def connect
0
+ EventMachine.connect(@host, @port, SwiftiplyConnection, &method(:initialize_connection))
0
+ end
0
+
0
+ # Stops the server
0
+ def disconnect
0
+ EventMachine.stop
0
+ end
0
+
0
+ def to_s
0
+ "#{@host}:#{@port} swiftiply"
0
+ end
0
+ end
0
+ end
0
+
0
+ class SwiftiplyConnection < Connection
0
+ def connection_completed
0
+ send_data swiftiply_handshake(@backend.key)
0
+ end
0
+
0
+ def persistent?
0
+ true
0
+ end
0
+
0
+ def unbind
0
+ super
0
+ EventMachine.add_timer(rand(2)) { reconnect(@backend.host, @backend.port) } if @backend.running?
0
+ end
0
+
0
+ protected
0
+ def swiftiply_handshake(key)
0
+ 'swiftclient' << host_ip.collect { |x| sprintf('%02x', x.to_i)}.join << sprintf('%04x', @backend.port) << sprintf('%02x', key.length) << key
0
+ end
0
+
0
+ # For some reason Swiftiply request the current host
0
+ def host_ip
0
+ Socket.gethostbyname(@backend.host)[3].unpack('CCCC') rescue [0,0,0,0]
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -1 +1,30 @@
0
+module Thin
0
+ module Backends
0
+ # Connectior to act as a TCP socket server.
0
+ class TcpServer < Base
0
+ # Address and port on which the server is listening for connections.
0
+ attr_accessor :host, :port
0
+
0
+ def initialize(host, port)
0
+ @host = host
0
+ @port = port
0
+ super()
0
+ end
0
+
0
+ # Connect the server
0
+ def connect
0
+ @signature = EventMachine.start_server(@host, @port, Connection, &method(:initialize_connection))
0
+ end
0
+
0
+ # Stops the server
0
+ def disconnect
0
+ EventMachine.stop_server(@signature)
0
+ end
0
+
0
+ def to_s
0
+ "#{@host}:#{@port}"
0
+ end
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
0
@@ -1 +1,53 @@
0
+module Thin
0
+ module Backends
0
+ # Backend to act as a UNIX domain socket server.
0
+ class UnixServer < Base
0
+ # UNIX domain socket on which the server is listening for connections.
0
+ attr_accessor :socket
0
+
0
+ def initialize(socket)
0
+ raise PlatformNotSupported, 'UNIX sockets not available on Windows' if Thin.win?
0
+ @socket = socket
0
+ super()
0
+ end
0
+
0
+ # Connect the server
0
+ def connect
0
+ at_exit { remove_socket_file } # In case it crashes
0
+ EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection))
0
+ # HACK EventMachine.start_unix_domain_server doesn't return the connection signature
0
+ # so we have to go in the internal stuff to find it.
0
+ @signature = EventMachine.instance_eval{@acceptors.keys.first}
0
+ end
0
+
0
+ # Stops the server
0
+ def disconnect
0
+ EventMachine.stop_server(@signature)
0
+ end
0
+
0
+ # Free up resources used by the backend.
0
+ def close
0
+ remove_socket_file
0
+ end
0
+
0
+ def to_s
0
+ @socket
0
+ end
0
+
0
+ protected
0
+ def remove_socket_file
0
+ File.delete(@socket) if @socket && File.exist?(@socket)
0
+ end
0
+ end
0
+ end
0
+
0
+ # Connection through a UNIX domain socket.
0
+ class UnixConnection < Connection
0
+ protected
0
+ def socket_address
0
+ # FIXME not sure about this, does it even make sense on a UNIX socket?
0
+ Socket.unpack_sockaddr_un(get_peername)
0
+ end
0
+ end
0
+end
...
10
11
12
13
14
 
 
15
16
17
...
72
73
74
75
 
76
77
78
...
10
11
12
 
 
13
14
15
16
17
...
72
73
74
 
75
76
77
78
0
@@ -10,8 +10,8 @@
0
     # Rack application served by this connection.
0
     attr_accessor :app
0
     
0
- # Connector to the server
0
- attr_accessor :connector
0
+ # Backend to the server
0
+ attr_accessor :backend
0
     
0
     # Current request served by the connection
0
     attr_accessor :request
0
@@ -72,7 +72,7 @@
0
     # Called when the connection is unbinded from the socket
0
     # and can no longer be used to process requests.
0
     def unbind
0
- @connector.connection_finished(self)
0
+ @backend.connection_finished(self)
0
     end
0
     
0
     # Allows this connection to be persistent.
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,74 +1 @@
0
-module Thin
0
- module Connectors
0
- # A Connector connect the server to the client. It handles:
0
- # * connection/disconnection to the server
0
- # * initialization of the connections
0
- # * manitoring of the active connections.
0
- class Connector
0
- # Server serving the connections throught the connector
0
- attr_accessor :server
0
-
0
- # Maximum time for incoming data to arrive
0
- attr_accessor :timeout
0
-
0
- # Maximum number of connections that can be persistent
0
- attr_accessor :maximum_persistent_connections
0
-
0
- # Number of persistent connections currently opened
0
- attr_accessor :persistent_connection_count
0
-
0
- def initialize
0
- @connections = []
0
- @timeout = Server::DEFAULT_TIMEOUT
0
- @persistent_connection_count = 0
0
- @maximum_persistent_connections = Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
0
- end
0
-
0
- # Free up resources used by the connector.
0
- def close
0
- end
0
-
0
- def running?
0
- @server.running?
0
- end
0
-
0
- # Initialize a new connection to a client.
0
- def initialize_connection(connection)
0
- connection.connector = self
0
- connection.app = @server.app
0
- connection.comm_inactivity_timeout = @timeout
0
-
0
- # We control the number of persistent connections by keeping
0
- # a count of the total one allowed yet.
0
- if @persistent_connection_count < @maximum_persistent_connections
0
- connection.can_persist!
0
- @persistent_connection_count += 1
0
- end
0
-
0
- @connections << connection
0
- end
0
-
0
- # Close all active connections.
0
- def close_connections
0
- @connections.each { |connection| connection.close_connection }
0
- end
0
-
0
- # Called by a connection when it's unbinded.
0
- def connection_finished(connection)
0
- @persistent_connection_count -= 1 if connection.can_persist?
0
- @connections.delete(connection)
0
- end
0
-
0
- # Returns +true+ if no active connection.
0
- def empty?
0
- @connections.empty?
0
- end
0
-
0
- # Number of active connections.
0
- def size
0
- @connections.size
0
- end
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,56 +1 @@
0
-module Thin
0
- module Connectors
0
- class SwiftiplyClient < Connector
0
- attr_accessor :key
0
-
0
- attr_accessor :host, :port
0
-
0
- def initialize(host, port, key=nil)
0
- @host = host
0
- @port = port.to_i
0
- @key = key || ''
0
- super()
0
- end
0
-
0
- # Connect the server
0
- def connect
0
- EventMachine.connect(@host, @port, SwiftiplyConnection, &method(:initialize_connection))
0
- end
0
-
0
- # Stops the server
0
- def disconnect
0
- EventMachine.stop
0
- end
0
-
0
- def to_s
0
- "#{@host}:#{@port} swiftiply"
0
- end
0
- end
0
- end
0
-
0
- class SwiftiplyConnection < Connection
0
- def connection_completed
0
- send_data swiftiply_handshake(@connector.key)
0
- end
0
-
0
- def persistent?
0
- true
0
- end
0
-
0
- def unbind
0
- super
0
- EventMachine.add_timer(rand(2)) { reconnect(@connector.host, @connector.port) } if @connector.running?
0
- end
0
-
0
- protected
0
- def swiftiply_handshake(key)
0
- 'swiftclient' << host_ip.collect { |x| sprintf('%02x', x.to_i)}.join << sprintf('%04x', @connector.port) << sprintf('%02x', key.length) << key
0
- end
0
-
0
- # For some reason Swiftiply request the current host
0
- def host_ip
0
- Socket.gethostbyname(@connector.host)[3].unpack('CCCC') rescue [0,0,0,0]
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,30 +1 @@
0
-module Thin
0
- module Connectors
0
- # Connectior to act as a TCP socket server.
0
- class TcpServer < Connector
0
- # Address and port on which the server is listening for connections.
0
- attr_accessor :host, :port
0
-
0
- def initialize(host, port)
0
- @host = host
0
- @port = port
0
- super()
0
- end
0
-
0
- # Connect the server
0
- def connect
0
- @signature = EventMachine.start_server(@host, @port, Connection, &method(:initialize_connection))
0
- end
0
-
0
- # Stops the server
0
- def disconnect
0
- EventMachine.stop_server(@signature)
0
- end
0
-
0
- def to_s
0
- "#{@host}:#{@port}"
0
- end
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,53 +1 @@
0
-module Thin
0
- module Connectors
0
- # Connector to act as a UNIX domain socket server.
0
- class UnixServer < Connector
0
- # UNIX domain socket on which the server is listening for connections.
0
- attr_accessor :socket
0
-
0
- def initialize(socket)
0
- raise PlatformNotSupported, 'UNIX sockets not available on Windows' if Thin.win?
0
- @socket = socket
0
- super()
0
- end
0
-
0
- # Connect the server
0
- def connect
0
- at_exit { remove_socket_file } # In case it crashes
0
- EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection))
0
- # HACK EventMachine.start_unix_domain_server doesn't return the connection signature
0
- # so we have to go in the internal stuff to find it.
0
- @signature = EventMachine.instance_eval{@acceptors.keys.first}
0
- end
0
-
0
- # Stops the server
0
- def disconnect
0
- EventMachine.stop_server(@signature)
0
- end
0
-
0
- # Free up resources used by the connector.
0
- def close
0
- remove_socket_file
0
- end
0
-
0
- def to_s
0
- @socket
0
- end
0
-
0
- protected
0
- def remove_socket_file
0
- File.delete(@socket) if @socket && File.exist?(@socket)
0
- end
0
- end
0
- end
0
-
0
- # Connection through a UNIX domain socket.
0
- class UnixConnection < Connection
0
- protected
0
- def socket_address
0
- # FIXME not sure about this, does it even make sense on a UNIX socket?
0
- Socket.unpack_sockaddr_un(get_peername)
0
- end
0
- end
0
-end
...
31
32
33
34
 
35
36
37
...
31
32
33
 
34
35
36
37
0
@@ -31,7 +31,7 @@
0
         when @options.has_key?(:socket)
0
           Server.new(@options[:socket])
0
         when @options.has_key?(:swiftiply)
0
- Server.new(Connectors::SwiftiplyClient.new(@options[:address], @options[:port], @options[:swiftiply]))
0
+ Server.new(Backends::SwiftiplyClient.new(@options[:address], @options[:port], @options[:swiftiply]))
0
         else
0
           Server.new(@options[:address], @options[:port])
0
         end
...
1
2
3
 
4
5
6
7
8
...
16
17
18
19
 
20
21
 
22
23
24
 
 
25
26
27
28
29
30
31
32
33
34
35
...
55
56
57
58
59
 
 
60
61
62
63
64
65
66
 
67
68
69
70
71
72
 
73
74
75
 
76
77
78
 
79
80
81
82
83
84
85
86
 
 
 
 
 
 
 
87
88
 
89
90
91
92
 
 
93
94
95
96
97
 
 
 
98
99
100
101
102
103
...
123
124
125
126
 
127
128
129
130
131
132
133
134
135
 
 
136
137
 
138
139
140
...
148
149
150
151
 
152
153
154
155
156
...
166
167
168
169
 
170
171
172
 
173
174
175
176
 
177
178
179
180
...
204
205
206
207
 
208
209
210
211
 
212
213
214
...
1
2
 
3
4
5
6
7
8
...
16
17
18
 
19
20
 
21
22
 
 
23
24
25
26
27
28
29
30
31
32
33
34
35
...
55
56
57
 
 
58
59
60
61
62
63
64
65
 
66
67
68
69
70
71
 
72
73
74
 
75
76
77
 
78
79
 
 
 
 
 
 
 
80
81
82
83
84
85
86
87
 
88
89
90
 
 
91
92
93
94
 
 
 
95
96
97
98
99
100
101
102
103
...
123
124
125
 
126
127
128
129
130
131
132
 
 
133
134
135
136
 
137
138
139
140
...
148
149
150
 
151
152
153
154
155
156
...
166
167
168
 
169
170
171
 
172
173
174
175
 
176
177
178
179
180
...
204
205
206
 
207
208
209
210
 
211
212
213
214
0
@@ -1,6 +1,6 @@
0
 module Thin
0
   # The uterly famous Thin HTTP server.
0
- # It listen for incoming request through a given connector
0
+ # It listen for incoming request through a given backend
0
   # and forward all request to +app+.
0
   #
0
   # == TCP server
0
0
0
@@ -16,12 +16,12 @@
0
   #
0
   # Thin::Server.start('/tmp/thin.sock', nil, app)
0
   #
0
- # == Using a custom connector
0
+ # == Using a custom backend
0
   # You can implement your own way to connect the server to its client by creating your
0
- # own Thin::Connectors::Connector class and pass it as the first argument.
0
+ # own Backend class and pass it as the first argument.
0
   #
0
- # connector = Thin::Connectors::MyFancyConnector.new('galaxy://faraway:1345')
0
- # Thin::Server.start(connector, nil, app)
0
+ # backend = Thin::Backends::MyFancyBackend.new('galaxy://faraway:1345')
0
+ # Thin::Server.start(backend, nil, app)
0
   #
0
   # == Rack application (+app+)
0
   # All requests will be processed through +app+ that must be a valid Rack adapter.
0
0
0
0
0
0
0
0
0
@@ -55,46 +55,46 @@
0
     # Application (Rack adapter) called with the request that produces the response.
0
     attr_accessor :app
0
     
0
- # Connector handling the connections to the clients.
0
- attr_accessor :connector
0
+ # Backend handling the connections to the clients.
0
+ attr_accessor :backend
0
     
0
     # Maximum number of file or socket descriptors that the server may open.
0
     attr_accessor :maximum_connections
0
     
0
     # Maximum number of seconds for incoming data to arrive before the connection
0
     # is dropped.
0
- def_delegators :@connector, :timeout, :timeout=
0
+ def_delegators :@backend, :timeout, :timeout=
0
     
0
     # Maximum number of connection that can be persistent at the same time.
0
     # Most browser never close the connection so most of the time they are closed
0
     # when the timeout occur. If we don't control the number of persistent connection,
0
     # if would be very easy to overflow the server for a DoS attack.
0
- def_delegators :@connector, :maximum_persistent_connections, :maximum_persistent_connections=
0
+ def_delegators :@backend, :maximum_persistent_connections, :maximum_persistent_connections=
0
     
0
     # Address and port on which the server is listening for connections.
0
- def_delegators :@connector, :host, :port
0
+ def_delegators :@backend, :host, :port
0
     
0
     # UNIX domain socket on which the server is listening for connections.
0
- def_delegator :@connector, :socket
0
+ def_delegator :@backend, :socket
0
     
0
- def initialize(host_or_socket_or_connector, port=DEFAULT_PORT, app=nil, &block)
0
- # Try to intelligently select which connector to use.
0
- @connector = case
0
- when host_or_socket_or_connector.is_a?(Connectors::Connector)
0
- host_or_socket_or_connector
0
- when host_or_socket_or_connector.include?('/')
0
- Connectors::UnixServer.new(host_or_socket_or_connector)
0
+ def initialize(host_or_socket_or_backend, port=DEFAULT_PORT, app=nil, &block)
0
+ # Try to intelligently select which backend to use.
0
+ @backend = case
0
+ when host_or_socket_or_backend.is_a?(Backends::Base)
0
+ host_or_socket_or_backend
0
+ when host_or_socket_or_backend.include?('/')
0
+ Backends::UnixServer.new(host_or_socket_or_backend)
0
       else
0
- Connectors::TcpServer.new(host_or_socket_or_connector, port.to_i)
0
+ Backends::TcpServer.new(host_or_socket_or_backend, port.to_i)
0
       end
0
 
0
- @app = app
0
- @connector.server = self
0
+ @app = app
0
+ @backend.server = self
0
       
0
       # Set defaults
0
- @maximum_connections = DEFAULT_MAXIMUM_CONNECTIONS
0
- @connector.maximum_persistent_connections = DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
0
- @connector.timeout = DEFAULT_TIMEOUT
0
+ @maximum_connections = DEFAULT_MAXIMUM_CONNECTIONS
0
+ @backend.maximum_persistent_connections = DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
0
+ @backend.timeout = DEFAULT_TIMEOUT
0
       
0
       # Allow using Rack builder as a block
0
       @app = Rack::Builder.new(&block).to_app if block
0
0
0
0
@@ -123,18 +123,18 @@
0
       raise ArgumentError, 'app required' unless @app
0
       
0
       setup_signals
0
-
0
+
0
       # See http://rubyeventmachine.com/pub/rdoc/files/EPOLL.html
0
       EventMachine.epoll
0
       
0
       log ">> Thin web server (v#{VERSION::STRING} codename #{VERSION::CODENAME})"
0
       debug ">> Debugging ON"
0
       trace ">> Tracing ON"
0
-
0
- log ">> Listening on #{@connector}, CTRL+C to stop"
0
       
0
+ log ">> Listening on #{@backend}, CTRL+C to stop"
0
+
0
       @running = true
0
- EventMachine.run { @connector.connect }
0
+ EventMachine.run { @backend.connect }
0
     end
0
     alias :start! :start
0
     
0
@@ -148,7 +148,7 @@
0
         @running = false
0
         
0
         # Do not accept anymore connection
0
- @connector.disconnect
0
+ @backend.disconnect
0
         
0
         unless wait_for_connections_and_stop
0
           # Still some connections running, schedule a check later
0
0
0
@@ -166,14 +166,14 @@
0
     def stop!
0
       log ">> Stopping ..."
0
 
0
- @connector.close_connections
0
+ @backend.close_connections
0
       EventMachine.stop
0
 
0
- @connector.close
0
+ @backend.close
0
     end
0
         
0
     def name
0
- "thin server (#{@connector})"
0
+ "thin server (#{@backend})"
0
     end
0
     alias :to_s :name
0
     
0
0
@@ -204,11 +204,11 @@
0
     
0
     protected