passenger 3.0.8 → 3.0.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (42) hide show
  1. data/NEWS +9 -0
  2. data/bin/passenger-install-nginx-module +1 -1
  3. data/build/basics.rb +0 -1
  4. data/build/cxx_tests.rb +5 -0
  5. data/build/rpm.rb +1 -1
  6. data/doc/Users guide Apache.html +1 -1
  7. data/doc/Users guide Nginx.html +1 -1
  8. data/ext/apache2/Configuration.cpp +12 -0
  9. data/ext/apache2/Configuration.hpp +12 -1
  10. data/ext/apache2/Hooks.cpp +2 -0
  11. data/ext/common/AgentsStarter.cpp +4 -0
  12. data/ext/common/AgentsStarter.h +2 -0
  13. data/ext/common/AgentsStarter.hpp +4 -0
  14. data/ext/common/Constants.h +1 -1
  15. data/ext/common/Logging.h +481 -261
  16. data/ext/common/LoggingAgent/LoggingServer.h +10 -4
  17. data/ext/common/LoggingAgent/Main.cpp +7 -2
  18. data/ext/common/LoggingAgent/RemoteSender.h +25 -3
  19. data/ext/common/MessageChannel.h +18 -227
  20. data/ext/common/MessageClient.h +95 -92
  21. data/ext/common/Utils/IOUtils.cpp +114 -1
  22. data/ext/common/Utils/IOUtils.h +57 -1
  23. data/ext/common/Utils/MessageIO.h +576 -0
  24. data/ext/nginx/Configuration.c +35 -0
  25. data/ext/nginx/Configuration.h +2 -0
  26. data/ext/nginx/ContentHandler.c +17 -6
  27. data/ext/nginx/ngx_http_passenger_module.c +8 -0
  28. data/lib/phusion_passenger.rb +2 -2
  29. data/lib/phusion_passenger/analytics_logger.rb +174 -117
  30. data/lib/phusion_passenger/app_process.rb +14 -2
  31. data/test/cxx/CxxTestMain.cpp +14 -19
  32. data/test/cxx/IOUtilsTest.cpp +68 -18
  33. data/test/cxx/LoggingTest.cpp +20 -24
  34. data/test/cxx/MessageChannelTest.cpp +1 -1
  35. data/test/cxx/MessageIOTest.cpp +310 -0
  36. data/test/cxx/TestSupport.cpp +47 -0
  37. data/test/cxx/TestSupport.h +8 -0
  38. data/test/ruby/analytics_logger_spec.rb +20 -28
  39. data/test/tut/tut.h +2 -0
  40. metadata +11 -11
  41. data/build/rdoctask.rb +0 -209
  42. data/test/cxx/HttpStatusExtractorTest.cpp +0 -198
@@ -1,5 +1,6 @@
1
1
  #include <dirent.h>
2
2
  #include <unistd.h>
3
+ #include <fcntl.h>
3
4
  #include <pwd.h>
4
5
  #include <grp.h>
5
6
  #include "TestSupport.h"
@@ -54,6 +55,52 @@ readAll(int fd) {
54
55
  return result;
55
56
  }
56
57
 
58
+ void
59
+ writeUntilFull(int fd) {
60
+ int flags, ret;
61
+ char buf[1024];
62
+
63
+ memset(buf, 0, sizeof(buf));
64
+ flags = fcntl(fd, F_GETFL);
65
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
66
+
67
+ while (true) {
68
+ ret = write(fd, buf, sizeof(buf));
69
+ if (ret == -1) {
70
+ int e = errno;
71
+ if (e == EAGAIN) {
72
+ break;
73
+ } else {
74
+ throw SystemException("write() failed", e);
75
+ }
76
+ }
77
+ }
78
+ while (true) {
79
+ ret = write(fd, buf, 50);
80
+ if (ret == -1) {
81
+ int e = errno;
82
+ if (e == EAGAIN) {
83
+ break;
84
+ } else {
85
+ throw SystemException("write() failed", e);
86
+ }
87
+ }
88
+ }
89
+ while (true) {
90
+ ret = write(fd, buf, 1);
91
+ if (ret == -1) {
92
+ int e = errno;
93
+ if (e == EAGAIN) {
94
+ break;
95
+ } else {
96
+ throw SystemException("write() failed", e);
97
+ }
98
+ }
99
+ }
100
+
101
+ fcntl(fd, F_SETFL, flags);
102
+ }
103
+
57
104
  string
58
105
  replaceString(const string &str, const string &toFind, const string &replaceWith) {
59
106
  string::size_type pos = str.find(toFind);
@@ -92,6 +92,14 @@ string readAll(const string &filename);
92
92
  */
93
93
  string readAll(int fd);
94
94
 
95
+ /**
96
+ * Writes zeroes into the given file descriptor its buffer is full (i.e.
97
+ * the next write will block).
98
+ *
99
+ * @throws SystemException
100
+ */
101
+ void writeUntilFull(int fd);
102
+
95
103
  /**
96
104
  * Look for 'toFind' inside 'str', replace it with 'replaceWith' and return the result.
97
105
  * Only the first occurence of 'toFind' is replaced.
@@ -76,9 +76,10 @@ describe AnalyticsLogger do
76
76
  mock_time(TODAY)
77
77
 
78
78
  @logger.new_transaction("foobar").close(true)
79
- shared_data = @logger.instance_variable_get(:"@shared_data")
80
- shared_data.synchronize do
81
- shared_data.client.close
79
+ connection = @logger.instance_variable_get(:"@connection")
80
+ connection.synchronize do
81
+ connection.channel.close
82
+ connection.channel = nil
82
83
  end
83
84
 
84
85
  log = @logger.new_transaction("foobar")
@@ -92,24 +93,6 @@ describe AnalyticsLogger do
92
93
  File.read(log_file).should =~ /hello/
93
94
  end
94
95
 
95
- specify "#new_transaction reestablishes the connection to the logging server if the logging server crashed and was restarted" do
96
- mock_time(TODAY)
97
-
98
- @logger.new_transaction("foobar").close
99
- kill_agent
100
- start_agent
101
-
102
- log = @logger.new_transaction("foobar")
103
- begin
104
- log.message("hello")
105
- ensure
106
- log.close(true)
107
- end
108
-
109
- log_file = "#{@log_dir}/1/#{FOOBAR_MD5}/#{LOCALHOST_MD5}/requests/2010/04/11/12/log.txt"
110
- File.read(log_file).should =~ /hello/
111
- end
112
-
113
96
  specify "#new_transaction does not reconnect to the server for a short period of time if connecting failed" do
114
97
  @logger.reconnect_timeout = 60
115
98
  @logger.max_connect_tries = 1
@@ -157,9 +140,10 @@ describe AnalyticsLogger do
157
140
  log2 = @logger2.continue_transaction(log.txn_id, "foobar")
158
141
  log2.close(true)
159
142
 
160
- shared_data = @logger2.instance_variable_get(:"@shared_data")
161
- shared_data.synchronize do
162
- shared_data.client.close
143
+ connection = @logger2.instance_variable_get(:"@connection")
144
+ connection.synchronize do
145
+ connection.channel.close
146
+ connection.channel = nil
163
147
  end
164
148
 
165
149
  log2 = @logger2.continue_transaction(log.txn_id, "foobar")
@@ -173,7 +157,7 @@ describe AnalyticsLogger do
173
157
  File.read(log_file).should =~ /hello/
174
158
  end
175
159
 
176
- specify "#continue_transaction reestablishes the connection to the logging server if the logging server crashed and was restarted" do
160
+ specify "#new_transaction and #continue_transaction eventually reestablish the connection to the logging server if the logging server crashed and was restarted" do
177
161
  mock_time(TODAY)
178
162
 
179
163
  log = @logger.new_transaction("foobar")
@@ -181,12 +165,20 @@ describe AnalyticsLogger do
181
165
  kill_agent
182
166
  start_agent
183
167
 
168
+ log = @logger.new_transaction("foobar")
169
+ log.should be_null
170
+ log2 = @logger2.continue_transaction("1234-abcd", "foobar")
171
+ log2.should be_null
172
+
173
+ mock_time(TODAY + 60)
174
+ log = @logger.new_transaction("foobar")
184
175
  log2 = @logger2.continue_transaction(log.txn_id, "foobar")
185
176
  begin
186
177
  log2.message("hello")
187
178
  ensure
188
179
  log2.close(true)
189
180
  end
181
+ log.close(true)
190
182
 
191
183
  log_file = "#{@log_dir}/1/#{FOOBAR_MD5}/#{LOCALHOST_MD5}/requests/2010/04/11/12/log.txt"
192
184
  File.read(log_file).should =~ /hello/
@@ -243,9 +235,9 @@ describe AnalyticsLogger do
243
235
  specify "#clear_connection closes the connection" do
244
236
  @logger.new_transaction("foobar").close
245
237
  @logger.clear_connection
246
- shared_data = @logger.instance_variable_get(:"@shared_data")
247
- shared_data.synchronize do
248
- shared_data.client.should be_nil
238
+ connection = @logger.instance_variable_get(:"@connection")
239
+ connection.synchronize do
240
+ connection.channel.should be_nil
249
241
  end
250
242
  end
251
243
  end
@@ -1100,6 +1100,7 @@ private:
1100
1100
  test_result::ex_ctor, ex);
1101
1101
  return tr;
1102
1102
  }
1103
+ /*
1103
1104
  catch (const std::exception& ex)
1104
1105
  {
1105
1106
  // test failed with std::exception
@@ -1122,6 +1123,7 @@ private:
1122
1123
  test_result::ex);
1123
1124
  return tr;
1124
1125
  }
1126
+ */
1125
1127
 
1126
1128
  // test passed
1127
1129
  test_result tr(name_,ti->first, current_test_name, test_result::ok);
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passenger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 8
10
- version: 3.0.8
9
+ - 9
10
+ version: 3.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Phusion - http://www.phusion.nl/
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-03 00:00:00 +02:00
18
+ date: 2011-09-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -118,7 +118,6 @@ files:
118
118
  - build/packagetask.rb
119
119
  - build/packaging.rb
120
120
  - build/rake_extensions.rb
121
- - build/rdoctask.rb
122
121
  - build/rpm.rb
123
122
  - build/ruby_extension.rb
124
123
  - build/ruby_tests.rb
@@ -234,6 +233,7 @@ files:
234
233
  - bin/passenger-memory-stats
235
234
  - bin/passenger-status
236
235
  - doc/ApplicationPool algorithm.txt
236
+ - doc/Architectural overview.html
237
237
  - doc/Architectural overview.txt
238
238
  - doc/definitions.h
239
239
  - doc/images/by_sa.png
@@ -274,11 +274,15 @@ files:
274
274
  - doc/images/spawn_server_architecture.svg
275
275
  - doc/images/typical_isolated_web_application.png
276
276
  - doc/images/typical_isolated_web_application.svg
277
+ - doc/Security of user switching support.html
277
278
  - doc/Security of user switching support.txt
278
279
  - doc/Users guide Apache with comments.html
280
+ - doc/Users guide Apache.html
279
281
  - doc/Users guide Apache.idmap.txt
280
282
  - doc/Users guide Apache.txt
283
+ - doc/Users guide Nginx.html
281
284
  - doc/Users guide Nginx.txt
285
+ - doc/Users guide Standalone.html
282
286
  - doc/Users guide Standalone.txt
283
287
  - doc/users_guide_snippets/analysis_and_system_maintenance.txt
284
288
  - doc/users_guide_snippets/appendix_a_about.txt
@@ -374,6 +378,7 @@ files:
374
378
  - ext/common/Utils/IOUtils.h
375
379
  - ext/common/Utils/MD5.h
376
380
  - ext/common/Utils/MemZeroGuard.h
381
+ - ext/common/Utils/MessageIO.h
377
382
  - ext/common/Utils/ProcessMetricsCollector.h
378
383
  - ext/common/Utils/ScopeGuard.h
379
384
  - ext/common/Utils/StreamBoyerMooreHorspool.h
@@ -1133,10 +1138,10 @@ files:
1133
1138
  - test/cxx/FileDescriptorTest.cpp
1134
1139
  - test/cxx/FilterSupportTest.cpp
1135
1140
  - test/cxx/HttpHeaderBuffererTest.cpp
1136
- - test/cxx/HttpStatusExtractorTest.cpp
1137
1141
  - test/cxx/IOUtilsTest.cpp
1138
1142
  - test/cxx/LoggingTest.cpp
1139
1143
  - test/cxx/MessageChannelTest.cpp
1144
+ - test/cxx/MessageIOTest.cpp
1140
1145
  - test/cxx/MessageReadersWritersTest.cpp
1141
1146
  - test/cxx/MessageServerTest.cpp
1142
1147
  - test/cxx/PoolOptionsTest.cpp
@@ -1504,11 +1509,6 @@ files:
1504
1509
  - test/stub/zsfa/header.png
1505
1510
  - test/stub/zsfa/index.html
1506
1511
  - test/stub/zsfa/zsfa.png
1507
- - doc/Users guide Apache.html
1508
- - doc/Users guide Nginx.html
1509
- - doc/Users guide Standalone.html
1510
- - doc/Security of user switching support.html
1511
- - doc/Architectural overview.html
1512
1512
  has_rdoc: true
1513
1513
  homepage: http://www.modrails.com/
1514
1514
  licenses: []
@@ -1,209 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rake'
4
- require 'rake/tasklib'
5
-
6
- module Rake
7
-
8
- # Create a documentation task that will generate the RDoc files for
9
- # a project.
10
- #
11
- # The RDocTask will create the following targets:
12
- #
13
- # [<b>:<em>rdoc</em></b>]
14
- # Main task for this RDOC task.
15
- #
16
- # [<b>:clobber_<em>rdoc</em></b>]
17
- # Delete all the rdoc files. This target is automatically
18
- # added to the main clobber target.
19
- #
20
- # [<b>:re<em>rdoc</em></b>]
21
- # Rebuild the rdoc files from scratch, even if they are not out
22
- # of date.
23
- #
24
- # Simple example:
25
- #
26
- # Rake::RDocTask.new do |rd|
27
- # rd.main = "README.rdoc"
28
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
29
- # end
30
- #
31
- # The +rd+ object passed to the block is an RDocTask object. See the
32
- # attributes list for the RDocTask class for available customization options.
33
- #
34
- # == Specifying different task names
35
- #
36
- # You may wish to give the task a different name, such as if you are
37
- # generating two sets of documentation. For instance, if you want to have a
38
- # development set of documentation including private methods:
39
- #
40
- # Rake::RDocTask.new(:rdoc_dev) do |rd|
41
- # rd.main = "README.doc"
42
- # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
43
- # rd.options << "--all"
44
- # end
45
- #
46
- # The tasks would then be named :<em>rdoc_dev</em>, :clobber_<em>rdoc_dev</em>, and
47
- # :re<em>rdoc_dev</em>.
48
- #
49
- # If you wish to have completely different task names, then pass a Hash as
50
- # first argument. With the <tt>:rdoc</tt>, <tt>:clobber_rdoc</tt> and
51
- # <tt>:rerdoc</tt> options, you can customize the task names to your liking.
52
- # For example:
53
- #
54
- # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force")
55
- #
56
- # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc_clean</tt> and
57
- # <tt>:rdoc:force</tt>.
58
- #
59
- class RDocTask < TaskLib
60
- # Name of the main, top level task. (default is :rdoc)
61
- attr_accessor :name
62
-
63
- # Name of directory to receive the html output files. (default is "html")
64
- attr_accessor :rdoc_dir
65
-
66
- # Title of RDoc documentation. (defaults to rdoc's default)
67
- attr_accessor :title
68
-
69
- # Name of file to be used as the main, top level file of the
70
- # RDoc. (default is none)
71
- attr_accessor :main
72
-
73
- # Name of template to be used by rdoc. (defaults to rdoc's default)
74
- attr_accessor :template
75
-
76
- # List of files to be included in the rdoc generation. (default is [])
77
- attr_accessor :rdoc_files
78
-
79
- # Additional list of options to be passed rdoc. (default is [])
80
- attr_accessor :options
81
-
82
- # Whether to run the rdoc process as an external shell (default is false)
83
- attr_accessor :external
84
-
85
- attr_accessor :inline_source
86
-
87
- # Create an RDoc task with the given name. See the RDocTask class overview
88
- # for documentation.
89
- def initialize(name = :rdoc) # :yield: self
90
- if name.is_a?(Hash)
91
- invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc]
92
- if !invalid_options.empty?
93
- raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}"
94
- end
95
- end
96
-
97
- @name = name
98
- @rdoc_files = Rake::FileList.new
99
- @rdoc_dir = 'html'
100
- @main = nil
101
- @title = nil
102
- @template = nil
103
- @external = false
104
- @inline_source = true
105
- @options = []
106
- yield self if block_given?
107
- define
108
- end
109
-
110
- # Create the tasks defined by this task lib.
111
- def define
112
- if rdoc_task_name != "rdoc"
113
- desc "Build the RDOC HTML Files"
114
- else
115
- desc "Build the #{rdoc_task_name} HTML Files"
116
- end
117
- task rdoc_task_name
118
-
119
- desc "Force a rebuild of the RDOC files"
120
- task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
121
-
122
- desc "Remove rdoc products"
123
- task clobber_task_name do
124
- rm_r rdoc_dir rescue nil
125
- end
126
-
127
- task :clobber => [clobber_task_name]
128
-
129
- directory @rdoc_dir
130
- task rdoc_task_name => [rdoc_target]
131
- file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
132
- rm_r @rdoc_dir rescue nil
133
- @before_running_rdoc.call if @before_running_rdoc
134
- args = option_list + @rdoc_files
135
- if @external
136
- argstring = args.join(' ')
137
- sh %{ruby -Ivendor vender/rd #{argstring}}
138
- else
139
- require 'rdoc/rdoc'
140
- RDoc::RDoc.new.document(args)
141
- end
142
- end
143
- self
144
- end
145
-
146
- def option_list
147
- result = @options.dup
148
- result << "-o" << @rdoc_dir
149
- result << "--main" << quote(main) if main
150
- result << "--title" << quote(title) if title
151
- result << "-T" << quote(template) if template
152
- result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S")
153
- result
154
- end
155
-
156
- def quote(str)
157
- if @external
158
- "'#{str}'"
159
- else
160
- str
161
- end
162
- end
163
-
164
- def option_string
165
- option_list.join(' ')
166
- end
167
-
168
- # The block passed to this method will be called just before running the
169
- # RDoc generator. It is allowed to modify RDocTask attributes inside the
170
- # block.
171
- def before_running_rdoc(&block)
172
- @before_running_rdoc = block
173
- end
174
-
175
- private
176
-
177
- def rdoc_target
178
- "#{rdoc_dir}/index.html"
179
- end
180
-
181
- def rdoc_task_name
182
- case name
183
- when Hash
184
- (name[:rdoc] || "rdoc").to_s
185
- else
186
- name.to_s
187
- end
188
- end
189
-
190
- def clobber_task_name
191
- case name
192
- when Hash
193
- (name[:clobber_rdoc] || "clobber_rdoc").to_s
194
- else
195
- "clobber_#{name}"
196
- end
197
- end
198
-
199
- def rerdoc_task_name
200
- case name
201
- when Hash
202
- (name[:rerdoc] || "rerdoc").to_s
203
- else
204
- "re#{name}"
205
- end
206
- end
207
-
208
- end
209
- end