mongrel 0.3.12.2 → 0.3.12.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/mongrel_rails +1 -0
- data/ext/http11/http11.c +2 -2
- data/lib/mongrel.rb +18 -4
- data/lib/mongrel/debug.rb +23 -3
- metadata +2 -2
data/Rakefile
CHANGED
data/bin/mongrel_rails
CHANGED
data/ext/http11/http11.c
CHANGED
@@ -135,7 +135,7 @@ void header_done(void *data, const char *at, size_t length)
|
|
135
135
|
|
136
136
|
ctype = rb_hash_aref(req, global_http_content_type);
|
137
137
|
if(ctype != Qnil) {
|
138
|
-
rb_hash_aset(req, global_content_type,
|
138
|
+
rb_hash_aset(req, global_content_type, ctype);
|
139
139
|
}
|
140
140
|
|
141
141
|
rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
|
@@ -520,7 +520,7 @@ void Init_http11()
|
|
520
520
|
DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
|
521
521
|
DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
|
522
522
|
DEF_GLOBAL(http_host, "HTTP_HOST");
|
523
|
-
DEF_GLOBAL(mongrel_version, "Mongrel 0.3.12.
|
523
|
+
DEF_GLOBAL(mongrel_version, "Mongrel 0.3.12.3");
|
524
524
|
DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
|
525
525
|
DEF_GLOBAL(port_80, "80");
|
526
526
|
|
data/lib/mongrel.rb
CHANGED
@@ -99,7 +99,7 @@ module Mongrel
|
|
99
99
|
# The original URI requested by the client. Passed to URIClassifier to build PATH_INFO and SCRIPT_NAME.
|
100
100
|
REQUEST_URI='REQUEST_URI'.freeze
|
101
101
|
|
102
|
-
MONGREL_VERSION="0.3.12.
|
102
|
+
MONGREL_VERSION="0.3.12.3".freeze
|
103
103
|
|
104
104
|
# The standard empty 404 response for bad requests. Use Error4040Handler for custom stuff.
|
105
105
|
ERROR_404_RESPONSE="HTTP/1.1 404 Not Found\r\nConnection: close\r\nServer: #{MONGREL_VERSION}\r\n\r\nNOT FOUND".freeze
|
@@ -370,6 +370,8 @@ module Mongrel
|
|
370
370
|
attr_reader :acceptor
|
371
371
|
attr_reader :workers
|
372
372
|
attr_reader :classifier
|
373
|
+
attr_reader :host
|
374
|
+
attr_reader :port
|
373
375
|
|
374
376
|
# Creates a working server on host:port (strange things happen if port isn't a Number).
|
375
377
|
# Use HttpServer::run to start the server and HttpServer.acceptor.join to
|
@@ -392,6 +394,7 @@ module Mongrel
|
|
392
394
|
@workers = ThreadGroup.new
|
393
395
|
@timeout = timeout
|
394
396
|
@num_processors = num_processors
|
397
|
+
@death_time = 60
|
395
398
|
end
|
396
399
|
|
397
400
|
|
@@ -417,6 +420,7 @@ module Mongrel
|
|
417
420
|
params[Const::PATH_INFO] = path_info
|
418
421
|
params[Const::SCRIPT_NAME] = script_name
|
419
422
|
params[Const::REMOTE_ADDR] = params[Const::HTTP_X_FORWARDED_FOR] || client.peeraddr.last
|
423
|
+
|
420
424
|
request = HttpRequest.new(params, data[nread ... data.length], client)
|
421
425
|
response = HttpResponse.new(client)
|
422
426
|
|
@@ -464,7 +468,9 @@ module Mongrel
|
|
464
468
|
def reap_dead_workers(worker_list)
|
465
469
|
mark = Time.now
|
466
470
|
worker_list.each do |w|
|
467
|
-
|
471
|
+
w[:started_on] = Time.now if not w[:started_on]
|
472
|
+
|
473
|
+
if mark - w[:started_on] > @death_time + @timeout
|
468
474
|
STDERR.puts "Thread #{w.inspect} is too old, killing."
|
469
475
|
w.raise(StopServer.new("Timed out thread."))
|
470
476
|
end
|
@@ -482,6 +488,7 @@ module Mongrel
|
|
482
488
|
begin
|
483
489
|
client = @socket.accept
|
484
490
|
worker_list = @workers.list
|
491
|
+
|
485
492
|
if worker_list.length >= @num_processors
|
486
493
|
STDERR.puts "Server overloaded with #{worker_list.length} processors (#@num_processors max). Dropping connection."
|
487
494
|
client.close
|
@@ -510,10 +517,15 @@ module Mongrel
|
|
510
517
|
# now that processing is done we feed enough false onto the request queue to get
|
511
518
|
# each processor to exit and stop processing.
|
512
519
|
|
513
|
-
# finally we wait until the queue is empty
|
520
|
+
# finally we wait until the queue is empty (but only about 10 seconds)
|
521
|
+
@death_time = 10
|
522
|
+
shutdown_start = Time.now
|
523
|
+
|
514
524
|
while @workers.list.length > 0
|
515
|
-
|
525
|
+
waited_for = (Time.now - shutdown_start).ceil
|
526
|
+
STDERR.print "Shutdown waited #{waited_for} for #{@workers.list.length} requests, could take #{@death_time + @timeout} seconds.\r" if @workers.list.length > 0
|
516
527
|
sleep 1
|
528
|
+
reap_dead_workers(@workers.list)
|
517
529
|
end
|
518
530
|
end
|
519
531
|
|
@@ -802,11 +814,13 @@ module Mongrel
|
|
802
814
|
MongrelDbg.begin_trace :objects
|
803
815
|
MongrelDbg.begin_trace :rails
|
804
816
|
MongrelDbg.begin_trace :files
|
817
|
+
MongrelDbg.begin_trace :threads
|
805
818
|
|
806
819
|
uri location, :handler => plugin("/handlers/requestlog::access")
|
807
820
|
uri location, :handler => plugin("/handlers/requestlog::files")
|
808
821
|
uri location, :handler => plugin("/handlers/requestlog::objects")
|
809
822
|
uri location, :handler => plugin("/handlers/requestlog::params")
|
823
|
+
uri location, :handler => plugin("/handlers/requestlog::threads")
|
810
824
|
end
|
811
825
|
|
812
826
|
# Used to allow you to let users specify their own configurations
|
data/lib/mongrel/debug.rb
CHANGED
@@ -148,7 +148,7 @@ module RequestLog
|
|
148
148
|
include Mongrel::HttpHandlerPlugin
|
149
149
|
|
150
150
|
def process(request, response)
|
151
|
-
MongrelDbg::trace(:objects, "#{Time.now} OBJECT STATS BEFORE REQUEST #{request.params['PATH_INFO']}")
|
151
|
+
MongrelDbg::trace(:objects, "#{'-' * 10}\n#{Time.now} OBJECT STATS BEFORE REQUEST #{request.params['PATH_INFO']}")
|
152
152
|
ObjectTracker.sample
|
153
153
|
end
|
154
154
|
|
@@ -164,10 +164,30 @@ module RequestLog
|
|
164
164
|
end
|
165
165
|
|
166
166
|
end
|
167
|
+
|
168
|
+
class Threads < GemPlugin::Plugin "/handlers"
|
169
|
+
include Mongrel::HttpHandlerPlugin
|
170
|
+
|
171
|
+
def process(request, response)
|
172
|
+
MongrelDbg::trace(:threads, "#{Time.now} REQUEST #{request.params['PATH_INFO']}")
|
173
|
+
ObjectSpace.each_object do |obj|
|
174
|
+
if obj.class == Mongrel::HttpServer
|
175
|
+
worker_list = obj.workers.list
|
176
|
+
|
177
|
+
if worker_list.length > 0
|
178
|
+
keys = "-----\n\tKEYS:"
|
179
|
+
worker_list.each {|t| keys << "\n\t\t-- #{t}: #{t.keys.inspect}" }
|
180
|
+
end
|
181
|
+
|
182
|
+
MongrelDbg::trace(:threads, "#{obj.host}:#{obj.port} -- THREADS: #{worker_list.length} #{keys}")
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
167
187
|
end
|
168
188
|
|
169
189
|
|
170
190
|
END {
|
171
|
-
MongrelDbg::trace(:files, "FILES OPEN AT EXIT")
|
172
|
-
log_open_files
|
191
|
+
MongrelDbg::trace(:files, "FILES OPEN AT EXIT")
|
192
|
+
log_open_files
|
173
193
|
}
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mongrel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.12.
|
7
|
-
date: 2006-04-
|
6
|
+
version: 0.3.12.3
|
7
|
+
date: 2006-04-06 00:00:00 -04:00
|
8
8
|
summary: A small fast HTTP library and server that runs Rails, Camping, and Nitro apps.
|
9
9
|
require_paths:
|
10
10
|
- lib
|