mongrel 0.3.12 → 0.3.12.1
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 +12 -6
- data/doc/rdoc/classes/Class.src/M000001.html +10 -10
- data/doc/rdoc/classes/Class.src/M000002.html +46 -46
- data/doc/rdoc/classes/Class.src/M000003.html +7 -7
- data/doc/rdoc/classes/Class.src/M000004.html +6 -6
- data/doc/rdoc/classes/IO.src/M000005.html +5 -5
- data/doc/rdoc/classes/IO.src/M000006.html +5 -5
- data/doc/rdoc/classes/Kernel.src/M000025.html +5 -5
- data/doc/rdoc/classes/Kernel.src/M000026.html +11 -11
- data/doc/rdoc/classes/Mongrel.html +1 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +1 -1
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +10 -10
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +9 -9
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000101.html +4 -4
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +18 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +5 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +16 -16
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +19 -19
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +4 -4
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +10 -11
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +5 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +8 -8
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +7 -7
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +4 -4
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +14 -13
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +5 -33
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +33 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +18 -0
- data/doc/rdoc/classes/Mongrel/Const.html +11 -1
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000116.html +5 -5
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000117.html +18 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +0 -185
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000072.html +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000073.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +3 -1
- data/doc/rdoc/classes/Mongrel/{StopServer.html → HttpParserError.html} +5 -11
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000118.html +15 -7
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000119.html +7 -7
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000120.html +7 -19
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000121.html +32 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +12 -12
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +6 -6
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +11 -11
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +8 -8
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +8 -8
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +9 -9
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +6 -6
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +10 -10
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +51 -50
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +10 -10
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +45 -45
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +14 -14
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000069.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000070.html +8 -8
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000071.html +4 -4
- data/doc/rdoc/classes/ObjectTracker.src/M000019.html +20 -22
- data/doc/rdoc/classes/RequestLog/Access.src/M000122.html +19 -0
- data/doc/rdoc/classes/RequestLog/Files.src/{M000121.html → M000123.html} +5 -5
- data/doc/rdoc/classes/RequestLog/Objects.src/{M000122.html → M000124.html} +5 -5
- data/doc/rdoc/classes/RequestLog/Params.src/{M000123.html → M000125.html} +5 -5
- data/doc/rdoc/classes/Stats.html +1 -1
- data/doc/rdoc/classes/Stats.src/M000012.html +2 -2
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
- data/doc/rdoc/files/lib/mongrel/command_rb.html +1 -1
- data/doc/rdoc/files/lib/mongrel/debug_rb.html +1 -1
- data/doc/rdoc/files/lib/mongrel/handlers_rb.html +1 -1
- data/doc/rdoc/files/lib/mongrel/stats_rb.html +1 -1
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/examples/random_thrash.rb +19 -0
- data/ext/http11/http11.c +57 -12
- data/ext/http11/http11_parser.c +58 -52
- data/lib/mongrel.rb +37 -10
- data/lib/mongrel/command.rb +1 -1
- data/lib/mongrel/debug.rb +39 -125
- data/lib/mongrel/handlers.rb +2 -2
- data/lib/mongrel/rails.rb +2 -1
- data/lib/mongrel/stats.rb +2 -2
- data/test/test_configurator.rb +2 -2
- data/test/test_debug.rb +2 -4
- data/test/test_http11.rb +76 -7
- data/test/test_stats.rb +6 -4
- data/test/test_uriclassifier.rb +0 -14
- metadata +12 -24
- data/doc/rdoc/classes/Mongrel/CGIWrapper.html +0 -383
- data/doc/rdoc/classes/Mongrel/Configurator.html +0 -563
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +0 -171
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000115.html +0 -18
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +0 -152
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +0 -222
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000117.html +0 -28
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +0 -371
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +0 -301
- data/doc/rdoc/classes/RequestLog.html +0 -113
- data/doc/rdoc/classes/RequestLog/Files.html +0 -144
- data/doc/rdoc/classes/RequestLog/Objects.html +0 -144
- data/doc/rdoc/classes/RequestLog/Params.html +0 -144
- data/doc/rdoc/fr_class_index.html +0 -60
- data/doc/rdoc/fr_file_index.html +0 -40
- data/doc/rdoc/fr_method_index.html +0 -149
- data/doc/rdoc/index.html +0 -24
- data/lib/http11.bundle +0 -0
@@ -10,15 +10,15 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 453</span>
|
14
|
+
453: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reap_dead_workers</span>(<span class="ruby-identifier">worker_list</span>)
|
15
|
+
454: <span class="ruby-identifier">mark</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
16
|
+
455: <span class="ruby-identifier">worker_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
|
17
|
+
456: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mark</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">w</span>[<span class="ruby-identifier">:started_on</span>] <span class="ruby-operator">></span> <span class="ruby-value">10</span> <span class="ruby-operator">*</span> <span class="ruby-ivar">@timeout</span>
|
18
|
+
457: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"Thread #{w.inspect} is too old, killing."</span>
|
19
|
+
458: <span class="ruby-identifier">w</span>.<span class="ruby-identifier">raise</span>(<span class="ruby-constant">StopServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"Timed out thread."</span>))
|
20
|
+
459: <span class="ruby-keyword kw">end</span>
|
21
|
+
460: <span class="ruby-keyword kw">end</span>
|
22
|
+
461: <span class="ruby-keyword kw">end</span></pre>
|
23
23
|
</body>
|
24
24
|
</html>
|
@@ -10,51 +10,51 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
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
|
-
495:
|
47
|
-
496: <span class="ruby-comment cmt"># now that processing is done we feed enough false onto the request queue to get</span>
|
48
|
-
497: <span class="ruby-comment cmt"># each processor to exit and stop processing.</span>
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 466</span>
|
14
|
+
466: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
|
15
|
+
467: <span class="ruby-constant">BasicSocket</span>.<span class="ruby-identifier">do_not_reverse_lookup</span>=<span class="ruby-keyword kw">true</span>
|
16
|
+
468:
|
17
|
+
469: <span class="ruby-ivar">@acceptor</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
18
|
+
470: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
19
|
+
471: <span class="ruby-keyword kw">begin</span>
|
20
|
+
472: <span class="ruby-identifier">client</span> = <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">accept</span>
|
21
|
+
473: <span class="ruby-identifier">worker_list</span> = <span class="ruby-ivar">@workers</span>.<span class="ruby-identifier">list</span>
|
22
|
+
474: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">worker_list</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@num_processors</span>
|
23
|
+
475: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"Server overloaded with #{worker_list.length} processors (#@num_processors max). Dropping connection."</span>
|
24
|
+
476: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
|
25
|
+
477: <span class="ruby-identifier">reap_dead_workers</span>(<span class="ruby-identifier">worker_list</span>)
|
26
|
+
478: <span class="ruby-keyword kw">else</span>
|
27
|
+
479: <span class="ruby-identifier">thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
28
|
+
480: <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
|
29
|
+
481: <span class="ruby-keyword kw">end</span>
|
30
|
+
482:
|
31
|
+
483: <span class="ruby-identifier">thread</span>[<span class="ruby-identifier">:started_on</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
32
|
+
484: <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">priority</span>=<span class="ruby-value">1</span>
|
33
|
+
485: <span class="ruby-ivar">@workers</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">thread</span>)
|
34
|
+
486:
|
35
|
+
487: <span class="ruby-identifier">sleep</span> <span class="ruby-ivar">@timeout</span><span class="ruby-operator">/</span><span class="ruby-value">100</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@timeout</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
36
|
+
488: <span class="ruby-keyword kw">end</span>
|
37
|
+
489: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">StopServer</span>
|
38
|
+
490: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Server stopped. Exiting."</span>
|
39
|
+
491: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">closed?</span>
|
40
|
+
492: <span class="ruby-keyword kw">break</span>
|
41
|
+
493: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EMFILE</span>
|
42
|
+
494: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Too many open files. Try increasing ulimits."</span>
|
43
|
+
495: <span class="ruby-identifier">sleep</span> <span class="ruby-value">0</span><span class="ruby-value">.5</span>
|
44
|
+
496: <span class="ruby-keyword kw">end</span>
|
45
|
+
497: <span class="ruby-keyword kw">end</span>
|
49
46
|
498:
|
50
|
-
499: <span class="ruby-comment cmt">#
|
51
|
-
500: <span class="ruby-
|
52
|
-
501:
|
53
|
-
502:
|
54
|
-
503: <span class="ruby-keyword kw">
|
55
|
-
504:
|
56
|
-
505:
|
57
|
-
506:
|
58
|
-
507:
|
47
|
+
499: <span class="ruby-comment cmt"># now that processing is done we feed enough false onto the request queue to get</span>
|
48
|
+
500: <span class="ruby-comment cmt"># each processor to exit and stop processing.</span>
|
49
|
+
501:
|
50
|
+
502: <span class="ruby-comment cmt"># finally we wait until the queue is empty</span>
|
51
|
+
503: <span class="ruby-keyword kw">while</span> <span class="ruby-ivar">@workers</span>.<span class="ruby-identifier">list</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
52
|
+
504: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"Shutdown waiting for #{@workers.list.length} requests"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@workers</span>.<span class="ruby-identifier">list</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
53
|
+
505: <span class="ruby-identifier">sleep</span> <span class="ruby-value">1</span>
|
54
|
+
506: <span class="ruby-keyword kw">end</span>
|
55
|
+
507: <span class="ruby-keyword kw">end</span>
|
56
|
+
508:
|
57
|
+
509: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@acceptor</span>
|
58
|
+
510: <span class="ruby-keyword kw">end</span></pre>
|
59
59
|
</body>
|
60
60
|
</html>
|
@@ -10,19 +10,19 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 516</span>
|
14
|
+
516: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">handler</span>)
|
15
|
+
517: <span class="ruby-identifier">script_name</span>, <span class="ruby-identifier">path_info</span>, <span class="ruby-identifier">handlers</span> = <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">resolve</span>(<span class="ruby-identifier">uri</span>)
|
16
|
+
518:
|
17
|
+
519: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">handlers</span>
|
18
|
+
520: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, [<span class="ruby-identifier">handler</span>])
|
19
|
+
521: <span class="ruby-keyword kw">else</span>
|
20
|
+
522: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path_info</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">or</span> (<span class="ruby-identifier">script_name</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SLASH</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">path_info</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SLASH</span>)
|
21
|
+
523: <span class="ruby-identifier">handlers</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">handler</span>
|
22
|
+
524: <span class="ruby-keyword kw">else</span>
|
23
|
+
525: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, [<span class="ruby-identifier">handler</span>])
|
24
|
+
526: <span class="ruby-keyword kw">end</span>
|
25
|
+
527: <span class="ruby-keyword kw">end</span>
|
26
|
+
528: <span class="ruby-keyword kw">end</span></pre>
|
27
27
|
</body>
|
28
28
|
</html>
|
@@ -10,9 +10,9 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 533</span>
|
14
|
+
533: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
|
15
|
+
534: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
|
16
|
+
535: <span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -10,13 +10,13 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 539</span>
|
14
|
+
539: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
|
15
|
+
540: <span class="ruby-identifier">stopper</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
|
16
|
+
541: <span class="ruby-identifier">exc</span> = <span class="ruby-constant">StopServer</span>.<span class="ruby-identifier">new</span>
|
17
|
+
542: <span class="ruby-ivar">@acceptor</span>.<span class="ruby-identifier">raise</span>(<span class="ruby-identifier">exc</span>)
|
18
|
+
543: <span class="ruby-keyword kw">end</span>
|
19
|
+
544: <span class="ruby-identifier">stopper</span>.<span class="ruby-identifier">priority</span> = <span class="ruby-value">10</span>
|
20
|
+
545: <span class="ruby-keyword kw">end</span></pre>
|
21
21
|
</body>
|
22
22
|
</html>
|
@@ -10,9 +10,9 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 548</span>
|
14
|
+
548: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">HttpServer</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-identifier">date</span>)
|
15
|
+
549: <span class="ruby-identifier">date</span>.<span class="ruby-identifier">gmtime</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC_1123_DATE_FORMAT</span>)
|
16
|
+
550: <span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
@@ -19,28 +19,26 @@
|
|
19
19
|
70: <span class="ruby-comment cmt"># Strings can't be tracked easily and are so numerous that they drown out all else</span>
|
20
20
|
71: <span class="ruby-comment cmt"># so we just ignore them in the counts.</span>
|
21
21
|
72: <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">each_object</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span>
|
22
|
-
73: <span class="ruby-
|
23
|
-
74:
|
24
|
-
75:
|
25
|
-
76:
|
26
|
-
77:
|
27
|
-
78: <span class="ruby-
|
28
|
-
79:
|
29
|
-
80: <span class="ruby-identifier">
|
30
|
-
81:
|
31
|
-
82: <span class="ruby-
|
22
|
+
73: <span class="ruby-identifier">ospace</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">object_id</span>
|
23
|
+
74: <span class="ruby-identifier">counts</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>] <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
|
24
|
+
75: <span class="ruby-identifier">counts</span>[<span class="ruby-identifier">obj</span>.<span class="ruby-identifier">class</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
25
|
+
76: <span class="ruby-keyword kw">end</span>
|
26
|
+
77:
|
27
|
+
78: <span class="ruby-identifier">dead_objects</span> = <span class="ruby-ivar">@active_objects</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">ospace</span>
|
28
|
+
79: <span class="ruby-identifier">new_objects</span> = <span class="ruby-identifier">ospace</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@active_objects</span>
|
29
|
+
80: <span class="ruby-identifier">live_objects</span> = <span class="ruby-identifier">ospace</span> <span class="ruby-operator">&</span> <span class="ruby-ivar">@active_objects</span>
|
30
|
+
81:
|
31
|
+
82: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">trace</span>(<span class="ruby-identifier">:objects</span>, <span class="ruby-node">"COUNTS: #{dead_objects.length},#{new_objects.length},#{live_objects.length}"</span>)
|
32
32
|
83:
|
33
|
-
84: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">
|
34
|
-
85:
|
35
|
-
86:
|
36
|
-
87:
|
37
|
-
88:
|
38
|
-
89: <span class="ruby-
|
39
|
-
90:
|
40
|
-
91: <span class="ruby-ivar">@active_objects</span
|
41
|
-
92:
|
42
|
-
93:
|
43
|
-
94: <span class="ruby-keyword kw">end</span>
|
44
|
-
95: <span class="ruby-keyword kw">end</span></pre>
|
33
|
+
84: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">tracing?</span> <span class="ruby-identifier">:objects</span>
|
34
|
+
85: <span class="ruby-identifier">top_20</span> = <span class="ruby-identifier">counts</span>.<span class="ruby-identifier">sort</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">a</span>,<span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-identifier">b</span>[<span class="ruby-value">1</span>] <span class="ruby-operator"><=></span> <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>]}[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">20</span>]
|
35
|
+
86: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">trace</span>(<span class="ruby-identifier">:objects</span>,<span class="ruby-node">"TOP 20: #{top_20.inspect}"</span>)
|
36
|
+
87: <span class="ruby-keyword kw">end</span>
|
37
|
+
88:
|
38
|
+
89: <span class="ruby-ivar">@active_objects</span> = <span class="ruby-identifier">live_objects</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">new_objects</span>
|
39
|
+
90:
|
40
|
+
91: [<span class="ruby-ivar">@active_objects</span>, <span class="ruby-identifier">top_20</span>]
|
41
|
+
92: <span class="ruby-keyword kw">end</span>
|
42
|
+
93: <span class="ruby-keyword kw">end</span></pre>
|
45
43
|
</body>
|
46
44
|
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>process (RequestLog::Access)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line 226</span>
|
14
|
+
226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>,<span class="ruby-identifier">response</span>)
|
15
|
+
227: <span class="ruby-identifier">p</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>
|
16
|
+
228: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{p['REMOTE_ADDR']} - [#{Mongrel::HttpServer.httpdate(Time.now)}] \"#{p['REQUEST_METHOD']} #{p["REQUEST_URI"]} HTTP/1.1\""</span>
|
17
|
+
229: <span class="ruby-keyword kw">end</span></pre>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -10,10 +10,10 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line 236</span>
|
14
|
+
236: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
15
|
+
237: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">trace</span>(<span class="ruby-identifier">:files</span>, <span class="ruby-node">"#{Time.now} FILES OPEN BEFORE REQUEST #{request.params['PATH_INFO']}"</span>)
|
16
|
+
238: <span class="ruby-identifier">log_open_files</span>
|
17
|
+
239: <span class="ruby-keyword kw">end</span></pre>
|
18
18
|
</body>
|
19
19
|
</html>
|
@@ -10,10 +10,10 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line 246</span>
|
14
|
+
246: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
15
|
+
247: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">trace</span>(<span class="ruby-identifier">:objects</span>, <span class="ruby-node">"#{Time.now} OBJECT STATS BEFORE REQUEST #{request.params['PATH_INFO']}"</span>)
|
16
|
+
248: <span class="ruby-constant">ObjectTracker</span>.<span class="ruby-identifier">sample</span>
|
17
|
+
249: <span class="ruby-keyword kw">end</span></pre>
|
18
18
|
</body>
|
19
19
|
</html>
|
@@ -10,10 +10,10 @@
|
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel/debug.rb, line 257</span>
|
14
|
+
257: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
15
|
+
258: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">trace</span>(<span class="ruby-identifier">:rails</span>, <span class="ruby-node">"#{Time.now} REQUEST #{request.params['PATH_INFO']}"</span>)
|
16
|
+
259: <span class="ruby-constant">MongrelDbg</span><span class="ruby-operator">::</span><span class="ruby-identifier">trace</span>(<span class="ruby-identifier">:rails</span>, <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>.<span class="ruby-identifier">to_yaml</span>)
|
17
|
+
260: <span class="ruby-keyword kw">end</span></pre>
|
18
18
|
</body>
|
19
19
|
</html>
|
data/doc/rdoc/classes/Stats.html
CHANGED
@@ -185,7 +185,7 @@ fly.
|
|
185
185
|
<div class="method-heading">
|
186
186
|
<a href="Stats.src/M000012.html" target="Code" class="method-signature"
|
187
187
|
onclick="popupCode('Stats.src/M000012.html');return false;">
|
188
|
-
<span class="method-name">dump</span><span class="method-args">(msg = ""
|
188
|
+
<span class="method-name">dump</span><span class="method-args">(msg = "", out=STDERR)</span>
|
189
189
|
</a>
|
190
190
|
</div>
|
191
191
|
|
@@ -11,8 +11,8 @@
|
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
13
|
<pre> <span class="ruby-comment cmt"># File lib/mongrel/stats.rb, line 41</span>
|
14
|
-
41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dump</span>(<span class="ruby-identifier">msg</span> = <span class="ruby-value str">""</span>)
|
15
|
-
42: <span class="ruby-
|
14
|
+
41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dump</span>(<span class="ruby-identifier">msg</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">out</span>=<span class="ruby-constant">STDERR</span>)
|
15
|
+
42: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"[#{@name}] #{msg} : SUM=#@sum, SUMSQ=#@sumsq, N=#@n, MEAN=#{mean}, SD=#{sd}, MIN=#@min, MAX=#@max"</span>
|
16
16
|
43: <span class="ruby-keyword kw">end</span></pre>
|
17
17
|
</body>
|
18
18
|
</html>
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Sun Apr 02 21:35:45 EDT 2006
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'socket'
|
2
|
+
devrand = open("/dev/random","r")
|
3
|
+
|
4
|
+
loop do
|
5
|
+
s = TCPSocket.new(ARGV[0],ARGV[1])
|
6
|
+
s.write("GET / HTTP/1.1\r\n")
|
7
|
+
total = 0
|
8
|
+
begin
|
9
|
+
loop do
|
10
|
+
r = devrand.read(10)
|
11
|
+
n = s.write(r)
|
12
|
+
total += n
|
13
|
+
end
|
14
|
+
rescue Object
|
15
|
+
STDERR.puts "#$!: #{total}"
|
16
|
+
end
|
17
|
+
s.close
|
18
|
+
sleep 1
|
19
|
+
end
|
data/ext/http11/http11.c
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
static VALUE mMongrel;
|
10
10
|
static VALUE cHttpParser;
|
11
11
|
static VALUE cURIClassifier;
|
12
|
+
static VALUE eHttpParserError;
|
12
13
|
static int id_handler_map;
|
13
14
|
|
14
15
|
static VALUE global_http_prefix;
|
@@ -23,7 +24,6 @@ static VALUE global_http_content_type;
|
|
23
24
|
static VALUE global_gateway_interface;
|
24
25
|
static VALUE global_gateway_interface_value;
|
25
26
|
static VALUE global_interface_value;
|
26
|
-
static VALUE global_remote_address;
|
27
27
|
static VALUE global_server_name;
|
28
28
|
static VALUE global_server_port;
|
29
29
|
static VALUE global_server_protocol;
|
@@ -33,15 +33,36 @@ static VALUE global_mongrel_version;
|
|
33
33
|
static VALUE global_server_software;
|
34
34
|
static VALUE global_port_80;
|
35
35
|
|
36
|
-
|
36
|
+
/** Defines common length and error messages for input length validation. */
|
37
|
+
#define DEF_MAX_LENGTH(N,length) const size_t MAX_##N##_LENGTH = length; const char *MAX_##N##_LENGTH_ERR = "HTTP element " # N " is longer than the " # length " allowed length.";
|
38
|
+
|
39
|
+
/** Validates the max length of given input and throws an HttpParserError exception if over. */
|
40
|
+
#define VALIDATE_MAX_LENGTH(len, N) if(len > MAX_##N##_LENGTH) { rb_raise(eHttpParserError, MAX_##N##_LENGTH_ERR); }
|
41
|
+
|
42
|
+
/** Defines global strings in the init method. */
|
43
|
+
#define DEF_GLOBAL(N, val) global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N);
|
44
|
+
|
45
|
+
|
46
|
+
/* Defines the maximum allowed lengths for various input elements.*/
|
47
|
+
DEF_MAX_LENGTH(FIELD_NAME, 256);
|
48
|
+
DEF_MAX_LENGTH(FIELD_VALUE, 80 * 1024);
|
49
|
+
DEF_MAX_LENGTH(REQUEST_URI, 512);
|
50
|
+
DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
|
51
|
+
DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32)));
|
52
|
+
|
37
53
|
|
38
54
|
void http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen)
|
39
55
|
{
|
40
56
|
char *ch, *end;
|
41
57
|
VALUE req = (VALUE)data;
|
42
|
-
VALUE v =
|
43
|
-
VALUE f =
|
58
|
+
VALUE v = Qnil;
|
59
|
+
VALUE f = Qnil;
|
44
60
|
|
61
|
+
VALIDATE_MAX_LENGTH(flen, FIELD_NAME);
|
62
|
+
VALIDATE_MAX_LENGTH(vlen, FIELD_VALUE);
|
63
|
+
|
64
|
+
v = rb_str_new(value, vlen);
|
65
|
+
f = rb_str_dup(global_http_prefix);
|
45
66
|
f = rb_str_buf_cat(f, field, flen);
|
46
67
|
|
47
68
|
for(ch = RSTRING(f)->ptr, end = ch + RSTRING(f)->len; ch < end; ch++) {
|
@@ -58,14 +79,20 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s
|
|
58
79
|
void request_method(void *data, const char *at, size_t length)
|
59
80
|
{
|
60
81
|
VALUE req = (VALUE)data;
|
61
|
-
VALUE val =
|
82
|
+
VALUE val = Qnil;
|
83
|
+
|
84
|
+
val = rb_str_new(at, length);
|
62
85
|
rb_hash_aset(req, global_request_method, val);
|
63
86
|
}
|
64
87
|
|
65
88
|
void request_uri(void *data, const char *at, size_t length)
|
66
89
|
{
|
67
90
|
VALUE req = (VALUE)data;
|
68
|
-
VALUE val =
|
91
|
+
VALUE val = Qnil;
|
92
|
+
|
93
|
+
VALIDATE_MAX_LENGTH(length, REQUEST_URI);
|
94
|
+
|
95
|
+
val = rb_str_new(at, length);
|
69
96
|
rb_hash_aset(req, global_request_uri, val);
|
70
97
|
}
|
71
98
|
|
@@ -73,7 +100,11 @@ void request_uri(void *data, const char *at, size_t length)
|
|
73
100
|
void query_string(void *data, const char *at, size_t length)
|
74
101
|
{
|
75
102
|
VALUE req = (VALUE)data;
|
76
|
-
VALUE val =
|
103
|
+
VALUE val = Qnil;
|
104
|
+
|
105
|
+
VALIDATE_MAX_LENGTH(length, QUERY_STRING);
|
106
|
+
|
107
|
+
val = rb_str_new(at, length);
|
77
108
|
rb_hash_aset(req, global_query_string, val);
|
78
109
|
}
|
79
110
|
|
@@ -93,10 +124,20 @@ void header_done(void *data, const char *at, size_t length)
|
|
93
124
|
VALUE temp = Qnil;
|
94
125
|
VALUE host = Qnil;
|
95
126
|
VALUE port = Qnil;
|
127
|
+
VALUE ctype = Qnil;
|
128
|
+
VALUE clen = Qnil;
|
96
129
|
char *colon = NULL;
|
97
130
|
|
98
|
-
|
99
|
-
|
131
|
+
clen = rb_hash_aref(req, global_http_content_length);
|
132
|
+
if(clen != Qnil) {
|
133
|
+
rb_hash_aset(req, global_content_length, clen);
|
134
|
+
}
|
135
|
+
|
136
|
+
ctype = rb_hash_aref(req, global_http_content_type);
|
137
|
+
if(ctype != Qnil) {
|
138
|
+
rb_hash_aset(req, global_content_type, Qnil);
|
139
|
+
}
|
140
|
+
|
100
141
|
rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
|
101
142
|
if((temp = rb_hash_aref(req, global_http_host)) != Qnil) {
|
102
143
|
// ruby better close strings off with a '\0' dammit
|
@@ -137,6 +178,7 @@ VALUE HttpParser_alloc(VALUE klass)
|
|
137
178
|
hp->query_string = query_string;
|
138
179
|
hp->http_version = http_version;
|
139
180
|
hp->header_done = header_done;
|
181
|
+
http_parser_init(hp);
|
140
182
|
|
141
183
|
obj = Data_Wrap_Struct(klass, NULL, HttpParser_free, hp);
|
142
184
|
|
@@ -215,8 +257,10 @@ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data)
|
|
215
257
|
http->data = (void *)req_hash;
|
216
258
|
http_parser_execute(http, RSTRING(data)->ptr, RSTRING(data)->len);
|
217
259
|
|
260
|
+
VALIDATE_MAX_LENGTH(http_parser_nread(http), HEADER);
|
261
|
+
|
218
262
|
if(http_parser_has_error(http)) {
|
219
|
-
rb_raise(
|
263
|
+
rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails.");
|
220
264
|
} else {
|
221
265
|
return INT2FIX(http_parser_nread(http));
|
222
266
|
}
|
@@ -471,16 +515,17 @@ void Init_http11()
|
|
471
515
|
DEF_GLOBAL(http_content_type, "HTTP_CONTENT_TYPE");
|
472
516
|
DEF_GLOBAL(gateway_interface, "GATEWAY_INTERFACE");
|
473
517
|
DEF_GLOBAL(gateway_interface_value, "CGI/1.2");
|
474
|
-
DEF_GLOBAL(remote_address, "REMOTE_ADDR");
|
475
518
|
DEF_GLOBAL(server_name, "SERVER_NAME");
|
476
519
|
DEF_GLOBAL(server_port, "SERVER_PORT");
|
477
520
|
DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
|
478
521
|
DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
|
479
522
|
DEF_GLOBAL(http_host, "HTTP_HOST");
|
480
|
-
DEF_GLOBAL(mongrel_version, "Mongrel 0.3.12");
|
523
|
+
DEF_GLOBAL(mongrel_version, "Mongrel 0.3.12.1");
|
481
524
|
DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
|
482
525
|
DEF_GLOBAL(port_80, "80");
|
483
526
|
|
527
|
+
eHttpParserError = rb_define_class_under(mMongrel, "HttpParserError", rb_eIOError);
|
528
|
+
|
484
529
|
cHttpParser = rb_define_class_under(mMongrel, "HttpParser", rb_cObject);
|
485
530
|
rb_define_alloc_func(cHttpParser, HttpParser_alloc);
|
486
531
|
rb_define_method(cHttpParser, "initialize", HttpParser_init,0);
|