passenger 2.0.4 → 2.0.5

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 (116) hide show
  1. data/Rakefile +1 -1
  2. data/bin/passenger-install-apache2-module +4 -3
  3. data/doc/ApplicationPool algorithm.txt +8 -4
  4. data/doc/Users guide.html +1 -1
  5. data/doc/cxxapi/ApplicationPoolServer_8h-source.html +630 -623
  6. data/doc/cxxapi/ApplicationPool_8h-source.html +1 -1
  7. data/doc/cxxapi/Application_8h-source.html +1 -1
  8. data/doc/cxxapi/Bucket_8h-source.html +1 -1
  9. data/doc/cxxapi/Configuration_8h-source.html +2 -2
  10. data/doc/cxxapi/DummySpawnManager_8h-source.html +1 -1
  11. data/doc/cxxapi/Exceptions_8h-source.html +1 -1
  12. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  13. data/doc/cxxapi/Logging_8h-source.html +1 -1
  14. data/doc/cxxapi/MessageChannel_8h-source.html +1 -1
  15. data/doc/cxxapi/SpawnManager_8h-source.html +1 -1
  16. data/doc/cxxapi/StandardApplicationPool_8h-source.html +258 -259
  17. data/doc/cxxapi/System_8h-source.html +1 -1
  18. data/doc/cxxapi/Utils_8h-source.html +1 -1
  19. data/doc/cxxapi/annotated.html +1 -1
  20. data/doc/cxxapi/classClient-members.html +1 -1
  21. data/doc/cxxapi/classClient.html +1 -1
  22. data/doc/cxxapi/classDirectoryMapper-members.html +1 -1
  23. data/doc/cxxapi/classDirectoryMapper.html +1 -1
  24. data/doc/cxxapi/classHooks-members.html +1 -1
  25. data/doc/cxxapi/classHooks.html +1 -1
  26. data/doc/cxxapi/classPassenger_1_1Application-members.html +1 -1
  27. data/doc/cxxapi/classPassenger_1_1Application.html +1 -1
  28. data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +1 -1
  29. data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +1 -1
  30. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -1
  31. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +1 -1
  32. data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +1 -1
  33. data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +1 -1
  34. data/doc/cxxapi/classPassenger_1_1BusyException-members.html +1 -1
  35. data/doc/cxxapi/classPassenger_1_1BusyException.html +1 -1
  36. data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +1 -1
  37. data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +1 -1
  38. data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -1
  39. data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +1 -1
  40. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -1
  41. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +1 -1
  42. data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +1 -1
  43. data/doc/cxxapi/classPassenger_1_1FileSystemException.html +1 -1
  44. data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -1
  45. data/doc/cxxapi/classPassenger_1_1IOException.html +1 -1
  46. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +1 -1
  47. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +1 -1
  48. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -1
  49. data/doc/cxxapi/classPassenger_1_1SpawnException.html +1 -1
  50. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +1 -1
  51. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +1 -1
  52. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +1 -1
  53. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +1 -1
  54. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +1 -1
  55. data/doc/cxxapi/classPassenger_1_1SystemException.html +1 -1
  56. data/doc/cxxapi/classPassenger_1_1TempFile-members.html +1 -1
  57. data/doc/cxxapi/classPassenger_1_1TempFile.html +1 -1
  58. data/doc/cxxapi/classPassenger_1_1Thread-members.html +1 -1
  59. data/doc/cxxapi/classPassenger_1_1Thread.html +1 -1
  60. data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption-members.html +1 -1
  61. data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption.html +1 -1
  62. data/doc/cxxapi/classboost_1_1this__thread_1_1enable__syscall__interruption-members.html +1 -1
  63. data/doc/cxxapi/classboost_1_1this__thread_1_1enable__syscall__interruption.html +1 -1
  64. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption-members.html +1 -1
  65. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption.html +1 -1
  66. data/doc/cxxapi/definitions_8h-source.html +1 -1
  67. data/doc/cxxapi/files.html +1 -1
  68. data/doc/cxxapi/functions.html +1 -1
  69. data/doc/cxxapi/functions_func.html +1 -1
  70. data/doc/cxxapi/functions_type.html +1 -1
  71. data/doc/cxxapi/functions_vars.html +1 -1
  72. data/doc/cxxapi/graph_legend.html +1 -1
  73. data/doc/cxxapi/group__Configuration.html +3 -3
  74. data/doc/cxxapi/group__Core.html +1 -1
  75. data/doc/cxxapi/group__Exceptions.html +1 -1
  76. data/doc/cxxapi/group__Hooks.html +1 -1
  77. data/doc/cxxapi/group__Support.html +1 -1
  78. data/doc/cxxapi/hierarchy.html +1 -1
  79. data/doc/cxxapi/inherits.html +1 -1
  80. data/doc/cxxapi/main.html +1 -1
  81. data/doc/cxxapi/modules.html +1 -1
  82. data/doc/cxxapi/namespacePassenger.html +1 -1
  83. data/doc/cxxapi/namespacePassenger_1_1InterruptableCalls.html +1 -1
  84. data/doc/cxxapi/namespacemembers.html +1 -1
  85. data/doc/cxxapi/namespacemembers_func.html +1 -1
  86. data/doc/cxxapi/namespacemembers_type.html +1 -1
  87. data/doc/cxxapi/namespaces.html +1 -1
  88. data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -1
  89. data/doc/cxxapi/structPassenger_1_1AnythingToString.html +1 -1
  90. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -1
  91. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +1 -1
  92. data/doc/rdoc/classes/PlatformInfo.html +1 -1
  93. data/doc/rdoc/created.rid +1 -1
  94. data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
  95. data/doc/rdoc/files/ext/passenger/native_support_c.html +1 -1
  96. data/doc/rdoc/files/lib/passenger/abstract_request_handler_rb.html +1 -1
  97. data/doc/rdoc/files/lib/passenger/abstract_server_rb.html +1 -1
  98. data/doc/rdoc/files/lib/passenger/application_rb.html +1 -1
  99. data/doc/rdoc/files/lib/passenger/constants_rb.html +1 -1
  100. data/doc/rdoc/files/lib/passenger/dependencies_rb.html +1 -1
  101. data/doc/rdoc/files/lib/passenger/exceptions_rb.html +1 -1
  102. data/doc/rdoc/files/lib/passenger/message_channel_rb.html +1 -1
  103. data/doc/rdoc/files/lib/passenger/platform_info_rb.html +1 -1
  104. data/doc/rdoc/files/lib/passenger/spawn_manager_rb.html +1 -1
  105. data/doc/rdoc/files/lib/passenger/utils_rb.html +1 -1
  106. data/ext/apache2/ApplicationPoolServer.h +7 -0
  107. data/ext/apache2/ApplicationPoolServerExecutable.cpp +7 -0
  108. data/ext/apache2/Configuration.h +1 -1
  109. data/ext/apache2/Hooks.cpp +22 -32
  110. data/ext/apache2/StandardApplicationPool.h +3 -4
  111. data/ext/apache2/System.cpp +12 -2
  112. data/ext/passenger/native_support.c +1 -1
  113. data/lib/passenger/dependencies.rb +13 -7
  114. data/lib/passenger/platform_info.rb +1 -1
  115. data/lib/passenger/railz/application_spawner.rb +9 -1
  116. metadata +2 -2
@@ -63,7 +63,7 @@
63
63
  </tr>
64
64
  <tr>
65
65
  <td>Modified:</td>
66
- <td>Mon Dec 01 14:19:08 +0100 2008</td>
66
+ <td>Fri Dec 05 12:57:36 +0100 2008</td>
67
67
  </tr>
68
68
  </table>
69
69
  </td></tr>
@@ -63,7 +63,7 @@
63
63
  </tr>
64
64
  <tr>
65
65
  <td>Modified:</td>
66
- <td>Mon Dec 01 14:19:08 +0100 2008</td>
66
+ <td>Fri Dec 05 12:57:36 +0100 2008</td>
67
67
  </tr>
68
68
  </table>
69
69
  </td></tr>
@@ -33,6 +33,7 @@
33
33
  #include <errno.h>
34
34
  #include <unistd.h>
35
35
  #include <signal.h>
36
+ #include <fcntl.h>
36
37
 
37
38
  #include "MessageChannel.h"
38
39
  #include "ApplicationPool.h"
@@ -507,6 +508,12 @@ private:
507
508
  } else { // Parent process.
508
509
  InterruptableCalls::close(fds[0]);
509
510
  serverSocket = fds[1];
511
+
512
+ int flags = fcntl(serverSocket, F_GETFD);
513
+ if (flags != -1) {
514
+ fcntl(serverSocket, F_SETFD, flags | FD_CLOEXEC);
515
+ }
516
+
510
517
  serverPid = pid;
511
518
  }
512
519
  }
@@ -415,6 +415,13 @@ int
415
415
  Server::start() {
416
416
  setupSyscallInterruptionSupport();
417
417
 
418
+ // Ignore SIGPIPE.
419
+ struct sigaction action;
420
+ action.sa_handler = SIG_IGN;
421
+ action.sa_flags = 0;
422
+ sigemptyset(&action.sa_mask);
423
+ sigaction(SIGPIPE, &action, NULL);
424
+
418
425
  try {
419
426
  if (!statusReportFIFO.empty()) {
420
427
  statusReportThread = ptr(
@@ -31,7 +31,7 @@
31
31
  */
32
32
 
33
33
  /** Module version number. */
34
- #define PASSENGER_VERSION "2.0.4"
34
+ #define PASSENGER_VERSION "2.0.5"
35
35
 
36
36
  #ifdef __cplusplus
37
37
  #include <set>
@@ -294,8 +294,8 @@ private:
294
294
  }
295
295
  };
296
296
 
297
- ApplicationPoolPtr applicationPool;
298
297
  ApplicationPoolServerPtr applicationPoolServer;
298
+ thread_specific_ptr<ApplicationPoolPtr> threadSpecificApplicationPool;
299
299
 
300
300
  DirConfig *getDirConfig(request_rec *r) {
301
301
  return (DirConfig *) ap_get_module_config(r->per_dir_config, &passenger_module);
@@ -305,6 +305,21 @@ private:
305
305
  return (ServerConfig *) ap_get_module_config(s->module_config, &passenger_module);
306
306
  }
307
307
 
308
+ /**
309
+ * When using the worker MPM and global queuing, deadlocks can occur, for
310
+ * the same reason described in ApplicationPoolServer::connect(). This
311
+ * method allows us to avoid this deadlock by making sure that each
312
+ * thread gets its own connection to the application pool server.
313
+ */
314
+ ApplicationPoolPtr getApplicationPool() {
315
+ ApplicationPoolPtr *pool_ptr = threadSpecificApplicationPool.get();
316
+ if (pool_ptr == NULL) {
317
+ pool_ptr = new ApplicationPoolPtr(applicationPoolServer->connect());
318
+ threadSpecificApplicationPool.reset(pool_ptr);
319
+ }
320
+ return *pool_ptr;
321
+ }
322
+
308
323
  int reportDocumentRootDeterminationError(request_rec *r) {
309
324
  ap_set_content_type(r, "text/html; charset=UTF-8");
310
325
  ap_rputs("<h1>Passenger error #1</h1>\n", r);
@@ -603,29 +618,12 @@ public:
603
618
  applicationPoolServerExe, spawnServer, "",
604
619
  ruby, user)
605
620
  );
606
- }
607
-
608
- void initChild(apr_pool_t *pchild, server_rec *s) {
609
- ServerConfig *config = getServerConfig(s);
610
621
 
611
- try {
612
- applicationPool = applicationPoolServer->connect();
613
- applicationPoolServer->detach();
614
- applicationPool->setMax(config->maxPoolSize);
615
- applicationPool->setMaxPerApp(config->maxInstancesPerApp);
616
- applicationPool->setMaxIdleTime(config->poolIdleTime);
617
- applicationPool->setUseGlobalQueue(config->getUseGlobalQueue());
618
- } catch (const thread_interrupted &) {
619
- P_TRACE(3, "A system call was interrupted during initialization of "
620
- "an Apache child process. Apache is probably restarting or "
621
- "shutting down.");
622
- } catch (const exception &e) {
623
- P_WARN("Cannot initialize Passenger in an Apache child process: " <<
624
- e.what() <<
625
- " (this warning is harmless if you're currently restarting "
626
- "or shutting down Apache)\n");
627
- abort();
628
- }
622
+ ApplicationPoolPtr pool(applicationPoolServer->connect());
623
+ pool->setMax(config->maxPoolSize);
624
+ pool->setMaxPerApp(config->maxInstancesPerApp);
625
+ pool->setMaxIdleTime(config->poolIdleTime);
626
+ pool->setUseGlobalQueue(config->getUseGlobalQueue());
629
627
  }
630
628
 
631
629
  int handleRequest(request_rec *r) {
@@ -694,7 +692,7 @@ public:
694
692
  spawnMethod = "smart";
695
693
  }
696
694
 
697
- session = applicationPool->get(
695
+ session = getApplicationPool()->get(
698
696
  canonicalizePath(mapper.getPublicDirectory() + "/.."),
699
697
  true, defaultUser, environment, spawnMethod,
700
698
  mapper.getApplicationTypeString());
@@ -953,13 +951,6 @@ init_module(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *
953
951
  }
954
952
  }
955
953
 
956
- static void
957
- init_child(apr_pool_t *pchild, server_rec *s) {
958
- if (hooks != NULL) {
959
- return hooks->initChild(pchild, s);
960
- }
961
- }
962
-
963
954
  static int
964
955
  handle_request(request_rec *r) {
965
956
  if (hooks != NULL) {
@@ -984,7 +975,6 @@ map_to_storage(request_rec *r) {
984
975
  void
985
976
  passenger_register_hooks(apr_pool_t *p) {
986
977
  ap_hook_post_config(init_module, NULL, NULL, APR_HOOK_MIDDLE);
987
- ap_hook_child_init(init_child, NULL, NULL, APR_HOOK_MIDDLE);
988
978
  ap_hook_map_to_storage(map_to_storage, NULL, NULL, APR_HOOK_FIRST);
989
979
  ap_hook_handler(handle_request, NULL, NULL, APR_HOOK_MIDDLE);
990
980
  }
@@ -449,11 +449,9 @@ private:
449
449
  activeOrMaxChanged.notify_all();
450
450
  }
451
451
  } else {
452
- while (!(
453
- active < max &&
454
- (maxPerApp == 0 || appInstanceCount[appRoot] < maxPerApp)
455
- )) {
452
+ if (active >= max) {
456
453
  activeOrMaxChanged.wait(l);
454
+ goto beginning_of_function;
457
455
  }
458
456
  if (count == max) {
459
457
  container = inactiveApps.front();
@@ -654,6 +652,7 @@ public:
654
652
  appInstanceCount.clear();
655
653
  count = 0;
656
654
  active = 0;
655
+ activeOrMaxChanged.notify_all();
657
656
  }
658
657
 
659
658
  virtual void setMaxIdleTime(unsigned int seconds) {
@@ -49,8 +49,18 @@ interruptionSignalHandler(int sig) {
49
49
 
50
50
  void
51
51
  Passenger::setupSyscallInterruptionSupport() {
52
- signal(INTERRUPTION_SIGNAL, interruptionSignalHandler);
53
- siginterrupt(INTERRUPTION_SIGNAL, 1);
52
+ struct sigaction action;
53
+ int ret;
54
+
55
+ action.sa_handler = interruptionSignalHandler;
56
+ action.sa_flags = 0;
57
+ sigemptyset(&action.sa_mask);
58
+ do {
59
+ ret = sigaction(INTERRUPTION_SIGNAL, &action, NULL);
60
+ } while (ret == -1 && errno == EINTR);
61
+ do {
62
+ ret = siginterrupt(INTERRUPTION_SIGNAL, 1);
63
+ } while (ret == -1 && errno == EINTR);
54
64
  }
55
65
 
56
66
 
@@ -237,7 +237,7 @@ close_all_file_descriptors(VALUE self, VALUE exceptions) {
237
237
 
238
238
  for (i = sysconf(_SC_OPEN_MAX) - 1; i >= 0; i--) {
239
239
  int is_exception = 0;
240
- for (j = 0; j < RARRAY(exceptions)->len && !is_exception; j++) {
240
+ for (j = 0; j < RARRAY_LEN(exceptions) && !is_exception; j++) {
241
241
  long fd = NUM2INT(rb_ary_entry(exceptions, j));
242
242
  is_exception = i == fd;
243
243
  }
@@ -185,15 +185,21 @@ module Dependencies # :nodoc: all
185
185
  Rake = Dependency.new do |dep|
186
186
  dep.name = "Rake"
187
187
  dep.define_checker do |result|
188
- rake = PlatformInfo.find_command("rake")
189
- if rake.nil?
190
- result.not_found
191
- else
188
+ bindir = File.dirname(PlatformInfo::RUBY)
189
+ rake = File.join(bindir, "rake")
190
+ if File.executable?(rake)
192
191
  result.found(rake)
192
+ else
193
+ rake = PlatformInfo.find_command("rake")
194
+ if rake.nil?
195
+ result.not_found
196
+ else
197
+ result.found(rake)
198
+ end
193
199
  end
194
200
  end
195
201
  dep.website = "http://rake.rubyforge.org/"
196
- dep.install_instructions = "Please install RubyGems first, then run <b>gem install rake</b>"
202
+ dep.install_instructions = "Please install RubyGems first, then run <b>#{PlatformInfo::GEM} install rake</b>"
197
203
  end
198
204
 
199
205
  Apache2 = Dependency.new do |dep|
@@ -294,7 +300,7 @@ module Dependencies # :nodoc: all
294
300
  result.not_found
295
301
  end
296
302
  end
297
- dep.install_instructions = "Please install RubyGems first, then run <b>gem install fastthread</b>"
303
+ dep.install_instructions = "Please install RubyGems first, then run <b>#{PlatformInfo::GEM} install fastthread</b>"
298
304
  end
299
305
 
300
306
  Rack = Dependency.new do |dep|
@@ -311,7 +317,7 @@ module Dependencies # :nodoc: all
311
317
  result.not_found
312
318
  end
313
319
  end
314
- dep.install_instructions = "Please install RubyGems first, then run <b>gem install rack</b>"
320
+ dep.install_instructions = "Please install RubyGems first, then run <b>#{PlatformInfo::GEM} install rack</b>"
315
321
  end
316
322
  end
317
323
 
@@ -268,7 +268,7 @@ public
268
268
  end
269
269
 
270
270
  # The absolute path to the current Ruby interpreter.
271
- RUBY = Config::CONFIG['bindir'] + '/' + Config::CONFIG['RUBY_INSTALL_NAME']
271
+ RUBY = Config::CONFIG['bindir'] + '/' + Config::CONFIG['RUBY_INSTALL_NAME'] + Config::CONFIG['EXEEXT']
272
272
  # The correct 'gem' command for this Ruby interpreter.
273
273
  GEM = determine_gem_command
274
274
 
@@ -23,6 +23,7 @@ require 'fcntl'
23
23
  require 'passenger/application'
24
24
  require 'passenger/abstract_server'
25
25
  require 'passenger/application'
26
+ require 'passenger/rack/request_handler'
26
27
  require 'passenger/railz/request_handler'
27
28
  require 'passenger/exceptions'
28
29
  require 'passenger/utils'
@@ -304,7 +305,14 @@ private
304
305
  end
305
306
 
306
307
  reader.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
307
- handler = RequestHandler.new(reader)
308
+
309
+ if Rails::VERSION::STRING >= '2.3.0'
310
+ rack_app = ::ActionController::Dispatcher.new
311
+ handler = Rack::RequestHandler.new(reader, rack_app)
312
+ else
313
+ handler = RequestHandler.new(reader)
314
+ end
315
+
308
316
  channel.write(Process.pid, handler.socket_name,
309
317
  handler.using_abstract_namespace?)
310
318
  channel.send_io(writer)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phusion - http://www.phusion.nl/
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-01 00:00:00 +01:00
12
+ date: 2008-12-05 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency