passenger 4.0.48 → 4.0.49

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 (218) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +36 -2
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG +16 -0
  7. data/Rakefile +0 -1
  8. data/build/apache2.rb +4 -4
  9. data/build/common_library.rb +18 -18
  10. data/build/cplusplus_support.rb +2 -2
  11. data/build/documentation.rb +1 -1
  12. data/build/integration_tests.rb +12 -4
  13. data/build/misc.rb +12 -7
  14. data/build/packaging.rb +14 -14
  15. data/build/preprocessor.rb +10 -10
  16. data/build/rake_extensions.rb +11 -11
  17. data/build/ruby_extension.rb +2 -2
  18. data/dev/ci/inituidgid +24 -0
  19. data/dev/ci/run_jenkins.sh +57 -0
  20. data/dev/ci/run_rpm_tests.sh +77 -0
  21. data/dev/{run_travis.sh → ci/run_travis.sh} +60 -4
  22. data/doc/Users guide Nginx.txt +2 -2
  23. data/doc/users_guide_snippets/environment_variables.txt +0 -2
  24. data/doc/users_guide_snippets/tips.txt +20 -1
  25. data/ext/apache2/Bucket.cpp +18 -18
  26. data/ext/apache2/Bucket.h +4 -4
  27. data/ext/apache2/Configuration.cpp +7 -7
  28. data/ext/apache2/Configuration.hpp +43 -43
  29. data/ext/apache2/DirectoryMapper.h +5 -5
  30. data/ext/apache2/Hooks.cpp +142 -142
  31. data/ext/apache2/MergeDirConfig.cpp +40 -40
  32. data/ext/common/Account.h +17 -17
  33. data/ext/common/AccountsDatabase.h +9 -9
  34. data/ext/common/AgentsStarter.cpp +2 -2
  35. data/ext/common/AgentsStarter.h +40 -40
  36. data/ext/common/ApplicationPool2/Common.h +10 -6
  37. data/ext/common/ApplicationPool2/ComponentInfo.h +2 -2
  38. data/ext/common/ApplicationPool2/DirectSpawner.h +17 -17
  39. data/ext/common/ApplicationPool2/DummySpawner.h +5 -5
  40. data/ext/common/ApplicationPool2/Group.h +54 -38
  41. data/ext/common/ApplicationPool2/Implementation.cpp +76 -49
  42. data/ext/common/ApplicationPool2/Options.h +98 -91
  43. data/ext/common/ApplicationPool2/Pool.h +70 -69
  44. data/ext/common/ApplicationPool2/Process.h +21 -21
  45. data/ext/common/ApplicationPool2/Session.h +11 -11
  46. data/ext/common/ApplicationPool2/SmartSpawner.h +60 -60
  47. data/ext/common/ApplicationPool2/Socket.h +19 -19
  48. data/ext/common/ApplicationPool2/Spawner.h +64 -72
  49. data/ext/common/ApplicationPool2/SpawnerFactory.h +4 -4
  50. data/ext/common/ApplicationPool2/SuperGroup.h +41 -41
  51. data/ext/common/BackgroundEventLoop.cpp +1 -1
  52. data/ext/common/BackgroundEventLoop.h +2 -2
  53. data/ext/common/Constants.h +1 -1
  54. data/ext/common/EventedBufferedInput.h +5 -5
  55. data/ext/common/EventedClient.h +51 -51
  56. data/ext/common/EventedMessageServer.h +39 -39
  57. data/ext/common/EventedServer.h +32 -32
  58. data/ext/common/Exceptions.h +23 -23
  59. data/ext/common/FileDescriptor.h +18 -18
  60. data/ext/common/Logging.cpp +1 -1
  61. data/ext/common/MessageClient.h +27 -27
  62. data/ext/common/MessageReadersWriters.h +79 -79
  63. data/ext/common/MessageServer.h +59 -59
  64. data/ext/common/RandomGenerator.h +12 -12
  65. data/ext/common/ResourceLocator.h +8 -8
  66. data/ext/common/SafeLibev.h +54 -25
  67. data/ext/common/ServerInstanceDir.h +31 -31
  68. data/ext/common/StaticString.h +50 -48
  69. data/ext/common/Utils.cpp +73 -78
  70. data/ext/common/Utils.h +6 -6
  71. data/ext/common/Utils/Base64.cpp +3 -3
  72. data/ext/common/Utils/Base64.h +7 -7
  73. data/ext/common/Utils/BlockingQueue.h +9 -9
  74. data/ext/common/Utils/BufferedIO.h +17 -17
  75. data/ext/common/Utils/CachedFileStat.hpp +16 -16
  76. data/ext/common/Utils/Dechunker.h +25 -25
  77. data/ext/common/Utils/FileChangeChecker.h +10 -10
  78. data/ext/common/Utils/MemZeroGuard.h +5 -5
  79. data/ext/common/Utils/MemoryBarrier.h +1 -1
  80. data/ext/common/Utils/MessageIO.h +61 -61
  81. data/ext/common/Utils/ProcessMetricsCollector.h +40 -40
  82. data/ext/common/Utils/ScopeGuard.h +7 -7
  83. data/ext/common/Utils/SpeedMeter.h +1 -1
  84. data/ext/common/Utils/StrIntUtils.cpp +13 -13
  85. data/ext/common/Utils/StrIntUtils.h +3 -3
  86. data/ext/common/Utils/StringScanning.h +5 -5
  87. data/ext/common/Utils/SystemMetricsCollector.h +2 -2
  88. data/ext/common/Utils/SystemTime.h +10 -10
  89. data/ext/common/Utils/Template.h +2 -2
  90. data/ext/common/Utils/Timer.h +6 -6
  91. data/ext/common/Utils/VariantMap.h +29 -29
  92. data/ext/common/agents/Base.cpp +19 -19
  93. data/ext/common/agents/HelperAgent/AgentOptions.h +1 -1
  94. data/ext/common/agents/HelperAgent/FileBackedPipe.h +6 -6
  95. data/ext/common/agents/HelperAgent/Main.cpp +44 -43
  96. data/ext/common/agents/HelperAgent/RequestHandler.cpp +4 -4
  97. data/ext/common/agents/HelperAgent/RequestHandler.h +29 -28
  98. data/ext/common/agents/HelperAgent/ScgiRequestParser.h +56 -50
  99. data/ext/common/agents/LoggingAgent/AdminController.h +8 -8
  100. data/ext/common/agents/LoggingAgent/DataStoreId.h +17 -17
  101. data/ext/common/agents/LoggingAgent/FilterSupport.h +167 -167
  102. data/ext/common/agents/LoggingAgent/LoggingServer.h +122 -122
  103. data/ext/common/agents/LoggingAgent/Main.cpp +7 -7
  104. data/ext/common/agents/LoggingAgent/RemoteSender.h +54 -54
  105. data/ext/common/agents/SpawnPreparer.cpp +4 -4
  106. data/ext/common/agents/TempDirToucher.c +2 -2
  107. data/ext/common/agents/Watchdog/AgentWatcher.cpp +47 -47
  108. data/ext/common/agents/Watchdog/HelperAgentWatcher.cpp +7 -7
  109. data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +7 -7
  110. data/ext/common/agents/Watchdog/Main.cpp +22 -22
  111. data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +9 -9
  112. data/ext/libeio/eio.c +1 -1
  113. data/ext/nginx/Configuration.c +30 -30
  114. data/ext/nginx/Configuration.h +1 -1
  115. data/ext/nginx/ContentHandler.c +54 -54
  116. data/ext/nginx/ContentHandler.h +3 -3
  117. data/ext/nginx/StaticContentHandler.c +2 -2
  118. data/ext/nginx/ngx_http_passenger_module.c +21 -21
  119. data/ext/oxt/detail/backtrace_enabled.hpp +1 -1
  120. data/ext/oxt/detail/context.hpp +1 -1
  121. data/ext/oxt/detail/spin_lock_darwin.hpp +4 -4
  122. data/ext/oxt/detail/spin_lock_gcc_x86.hpp +3 -3
  123. data/ext/oxt/detail/spin_lock_pthreads.hpp +4 -4
  124. data/ext/oxt/detail/tracable_exception_disabled.hpp +1 -1
  125. data/ext/oxt/dynamic_thread_group.hpp +18 -18
  126. data/ext/oxt/implementation.cpp +9 -8
  127. data/ext/oxt/macros.hpp +2 -2
  128. data/ext/oxt/system_calls.cpp +11 -11
  129. data/ext/oxt/system_calls.hpp +13 -13
  130. data/ext/oxt/thread.hpp +22 -14
  131. data/ext/ruby/passenger_native_support.c +55 -55
  132. data/lib/phusion_passenger.rb +24 -24
  133. data/lib/phusion_passenger/common_library.rb +2 -0
  134. data/lib/phusion_passenger/loader_shared_helpers.rb +18 -18
  135. data/lib/phusion_passenger/packaging.rb +9 -4
  136. data/lib/phusion_passenger/platform_info/apache.rb +45 -31
  137. data/lib/phusion_passenger/platform_info/compiler.rb +11 -11
  138. data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
  139. data/lib/phusion_passenger/request_handler/thread_handler.rb +8 -8
  140. data/lib/phusion_passenger/standalone/app_finder.rb +16 -16
  141. data/lib/phusion_passenger/standalone/command.rb +22 -22
  142. data/packaging/rpm/LICENSE.txt +19 -0
  143. data/packaging/rpm/Makefile +13 -0
  144. data/packaging/rpm/README.md +41 -0
  145. data/packaging/rpm/Vagrantfile +38 -0
  146. data/{rpm/Vagrantfile → packaging/rpm/Vagrantfile.centos} +0 -0
  147. data/packaging/rpm/build +170 -0
  148. data/packaging/rpm/create_project +41 -0
  149. data/packaging/rpm/git_update +88 -0
  150. data/packaging/rpm/image/Dockerfile +37 -0
  151. data/packaging/rpm/image/Gemfile +3 -0
  152. data/packaging/rpm/image/Gemfile.lock +12 -0
  153. data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +19 -0
  154. data/packaging/rpm/image/amazon2014-i386.cfg +96 -0
  155. data/packaging/rpm/image/amazon2014-x86_64.cfg +96 -0
  156. data/packaging/rpm/image/site-defaults.cfg +168 -0
  157. data/packaging/rpm/internal/build_tasks.rb +238 -0
  158. data/packaging/rpm/internal/dummygpg +11 -0
  159. data/packaging/rpm/internal/exec_build +42 -0
  160. data/packaging/rpm/internal/get_distro_arch +14 -0
  161. data/packaging/rpm/internal/get_distro_id +10 -0
  162. data/packaging/rpm/internal/git_update +27 -0
  163. data/packaging/rpm/internal/inituidgid +17 -0
  164. data/packaging/rpm/internal/my_init +344 -0
  165. data/packaging/rpm/internal/python27 +3 -0
  166. data/packaging/rpm/internal/repo_update +46 -0
  167. data/packaging/rpm/internal/setuser +26 -0
  168. data/packaging/rpm/internal/tracking_helper +40 -0
  169. data/packaging/rpm/jenkins_release +99 -0
  170. data/packaging/rpm/lib/build_tasks_support.rb +402 -0
  171. data/packaging/rpm/lib/preprocessor.rb +341 -0
  172. data/packaging/rpm/nginx_spec/404.html +119 -0
  173. data/packaging/rpm/nginx_spec/50x.html +119 -0
  174. data/packaging/rpm/nginx_spec/index.html +116 -0
  175. data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +13 -0
  176. data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
  177. data/packaging/rpm/nginx_spec/nginx-upgrade +13 -0
  178. data/packaging/rpm/nginx_spec/nginx-upgrade.8 +151 -0
  179. data/packaging/rpm/nginx_spec/nginx.conf +131 -0
  180. data/packaging/rpm/nginx_spec/nginx.init +144 -0
  181. data/packaging/rpm/nginx_spec/nginx.logrotate +13 -0
  182. data/packaging/rpm/nginx_spec/nginx.service +15 -0
  183. data/packaging/rpm/nginx_spec/nginx.spec.template +559 -0
  184. data/packaging/rpm/nginx_spec/nginx.sysconfig +4 -0
  185. data/packaging/rpm/nginx_spec/passenger.conf +9 -0
  186. data/packaging/rpm/nginx_spec/poweredby.png +0 -0
  187. data/{rpm → packaging/rpm/passenger_spec}/apache-passenger.conf.in +0 -0
  188. data/{rpm → packaging/rpm/passenger_spec}/config.json +0 -0
  189. data/{rpm → packaging/rpm/passenger_spec}/passenger.logrotate +0 -0
  190. data/{rpm → packaging/rpm/passenger_spec}/passenger.spec.template +58 -31
  191. data/{rpm → packaging/rpm/passenger_spec}/passenger_dynamic_thread_group.patch +0 -0
  192. data/{rpm → packaging/rpm/passenger_spec}/passenger_tests_default_config_example.patch +0 -0
  193. data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -0
  194. data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-gcc47-include-sys_types.patch +0 -0
  195. data/packaging/rpm/repo_update +114 -0
  196. data/packaging/rpm/setup-system +60 -0
  197. data/packaging/rpm/shell +10 -0
  198. data/resources/templates/standalone/config.erb +3 -1
  199. data/test/config.json.rpm-automation +1 -1
  200. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +11 -11
  201. data/test/cxx/ApplicationPool2/OptionsTest.cpp +5 -5
  202. data/test/cxx/ApplicationPool2/PoolTest.cpp +129 -89
  203. data/test/cxx/ApplicationPool2/ProcessTest.cpp +15 -15
  204. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +22 -22
  205. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +11 -11
  206. data/test/cxx/ScgiRequestParserTest.cpp +75 -61
  207. data/test/cxx/UtilsTest.cpp +86 -85
  208. data/test/gdbinit.example +3 -0
  209. data/test/integration_tests/nginx_tests.rb +3 -3
  210. data/test/integration_tests/source_packaging_test.rb +3 -1
  211. data/test/stub/nginx/nginx.conf.erb +8 -1
  212. data/test/support/nginx_controller.rb +7 -7
  213. metadata +62 -17
  214. metadata.gz.asc +7 -7
  215. data/build/rpm.rb +0 -128
  216. data/dev/rpmtool +0 -21
  217. data/dev/test_rpm_packaging.sh +0 -28
  218. data/rpm/get_distro_id.py +0 -4
@@ -217,7 +217,7 @@ appendULL(char *buf, unsigned long long value) {
217
217
  remainder = remainder / 10;
218
218
  size++;
219
219
  } while (remainder != 0);
220
-
220
+
221
221
  reverse(buf, size);
222
222
  return buf + size;
223
223
  }
@@ -228,13 +228,13 @@ static char *
228
228
  appendIntegerAsHex(char *buf, IntegerType value) {
229
229
  IntegerType remainder = value;
230
230
  unsigned int size = 0;
231
-
231
+
232
232
  do {
233
233
  buf[size] = hex_chars[remainder % 16];
234
234
  remainder = remainder / 16;
235
235
  size++;
236
236
  } while (remainder != 0);
237
-
237
+
238
238
  reverse(buf, size);
239
239
  return buf + size;
240
240
  }
@@ -298,7 +298,7 @@ appendSignalName(char *buf, int signo) {
298
298
  static char *
299
299
  appendSignalReason(char *buf, siginfo_t *info) {
300
300
  bool handled = true;
301
-
301
+
302
302
  switch (info->si_code) {
303
303
  SI_CODE_HANDLER(SI_USER);
304
304
  #ifdef SI_KERNEL
@@ -359,7 +359,7 @@ appendSignalReason(char *buf, siginfo_t *info) {
359
359
  }
360
360
  break;
361
361
  }
362
-
362
+
363
363
  if (info->si_code <= 0) {
364
364
  buf = appendText(buf, ", signal sent by PID ");
365
365
  buf = appendULL(buf, (unsigned long long) info->si_pid);
@@ -369,7 +369,7 @@ appendSignalReason(char *buf, siginfo_t *info) {
369
369
 
370
370
  buf = appendText(buf, ", si_addr=");
371
371
  buf = appendPointerAsString(buf, info->si_addr);
372
-
372
+
373
373
  return buf;
374
374
  }
375
375
 
@@ -514,7 +514,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
514
514
  char *end = messageBuf;
515
515
  end = appendULL(end, (unsigned long long) state.pid);
516
516
  *end = '\0';
517
-
517
+
518
518
  pid_t child = asyncFork();
519
519
  if (child == 0) {
520
520
  closeAllFileDescriptors(2, true);
@@ -584,7 +584,7 @@ dumpWithCrashWatch(AbortHandlerState &state) {
584
584
  close(p[1]);
585
585
  dup2(p[0], STDIN_FILENO);
586
586
  closeAllFileDescriptors(2, true);
587
-
587
+
588
588
  char *command = end;
589
589
  end = appendText(end, "exec ");
590
590
  end = appendText(end, backtraceSanitizerCommand);
@@ -1046,7 +1046,7 @@ abortHandler(int signo, siginfo_t *info, void *ctx) {
1046
1046
  * We work around this for anything in the same linkage unit by just definin
1047
1047
  * our own versions of the assert handler and abort.
1048
1048
  */
1049
-
1049
+
1050
1050
  #include <pthread.h>
1051
1051
 
1052
1052
  extern "C" int
@@ -1093,7 +1093,7 @@ installAbortHandler() {
1093
1093
  fflush(stderr);
1094
1094
  abort();
1095
1095
  }
1096
-
1096
+
1097
1097
  stack_t stack;
1098
1098
  stack.ss_sp = alternativeStack;
1099
1099
  stack.ss_size = alternativeStackSize;
@@ -1105,7 +1105,7 @@ installAbortHandler() {
1105
1105
  fflush(stderr);
1106
1106
  abort();
1107
1107
  }
1108
-
1108
+
1109
1109
  struct sigaction action;
1110
1110
  action.sa_sigaction = abortHandler;
1111
1111
  action.sa_flags = SA_RESETHAND | SA_SIGINFO;
@@ -1406,7 +1406,7 @@ initializeSyscallFailureSimulation(const char *processName) {
1406
1406
  string prefix = string(processName) + "=";
1407
1407
  vector<string> components;
1408
1408
  unsigned int i;
1409
-
1409
+
1410
1410
  // Lookup this process in the specification string.
1411
1411
  split(spec, ';', components);
1412
1412
  for (i = 0; i < components.size(); i++) {
@@ -1495,7 +1495,7 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1495
1495
  }
1496
1496
  srand(randomSeed);
1497
1497
  srandom(randomSeed);
1498
-
1498
+
1499
1499
  ignoreSigpipe();
1500
1500
  if (hasEnvOption("PASSENGER_ABORT_HANDLER", true)) {
1501
1501
  shouldDumpWithCrashWatch = hasEnvOption("PASSENGER_DUMP_WITH_CRASH_WATCH", true);
@@ -1512,7 +1512,7 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1512
1512
  }
1513
1513
  setvbuf(stdout, NULL, _IONBF, 0);
1514
1514
  setvbuf(stderr, NULL, _IONBF, 0);
1515
-
1515
+
1516
1516
  TRACE_POINT();
1517
1517
  try {
1518
1518
  if (argc == 1) {
@@ -1544,7 +1544,7 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1544
1544
  } else {
1545
1545
  options.readFrom((const char **) argv + 1, argc - 1);
1546
1546
  }
1547
-
1547
+
1548
1548
  #ifdef __linux__
1549
1549
  if (options.has("passenger_root")) {
1550
1550
  ResourceLocator locator(options.get("passenger_root", true));
@@ -1569,14 +1569,14 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1569
1569
  */
1570
1570
  string filename = options.get("debug_log_file");
1571
1571
  options.erase("debug_log_file");
1572
-
1572
+
1573
1573
  int fd = open(filename.c_str(), O_CREAT | O_WRONLY | O_APPEND, 0644);
1574
1574
  if (fd == -1) {
1575
1575
  int e = errno;
1576
1576
  throw FileSystemException("Cannot open debug log file " +
1577
1577
  filename, e, filename);
1578
1578
  }
1579
-
1579
+
1580
1580
  dup2(fd, STDOUT_FILENO);
1581
1581
  dup2(fd, STDERR_FILENO);
1582
1582
  close(fd);
@@ -1588,7 +1588,7 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1588
1588
  P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
1589
1589
  exit(1);
1590
1590
  }
1591
-
1591
+
1592
1592
  // Change process title.
1593
1593
  argv0 = strdup(argv[0]);
1594
1594
  strncpy(argv[0], processName, strlen(argv[0]));
@@ -1597,7 +1597,7 @@ initializeAgent(int argc, char *argv[], const char *processName) {
1597
1597
  }
1598
1598
 
1599
1599
  P_DEBUG("Random seed: " << randomSeed);
1600
-
1600
+
1601
1601
  return options;
1602
1602
  }
1603
1603
 
@@ -94,7 +94,7 @@ struct AgentOptions: public VariantMap {
94
94
  loggingAgentAddress = options.get("logging_agent_address");
95
95
  loggingAgentPassword = options.get("logging_agent_password");
96
96
  adminToolStatusPassword = options.get("admin_tool_status_password");
97
-
97
+
98
98
  // Optional options.
99
99
  prestartUrls = options.getStrSet("prestart_urls", false);
100
100
  requestSocketLink = options.get("request_socket_link", false);
@@ -276,7 +276,7 @@ private:
276
276
  );
277
277
  }
278
278
  break;
279
-
279
+
280
280
  case OPENING_FILE:
281
281
  file.writeBuffer.append(data, size);
282
282
  break;
@@ -285,7 +285,7 @@ private:
285
285
  file.writeBuffer.append(data, size);
286
286
  writeBufferToFile();
287
287
  break;
288
-
288
+
289
289
  default:
290
290
  abort();
291
291
  }
@@ -418,7 +418,7 @@ private:
418
418
  if (OXT_UNLIKELY(oldGeneration != generation)) {
419
419
  throw RuntimeException("Don't call the consumed callback after you've reset the FileBackedPipe!");
420
420
  }
421
-
421
+
422
422
  if (pthread_equal(pthread_self(), getLibev()->getCurrentThread())) {
423
423
  real_dataConsumed(consumed, done, oldGeneration);
424
424
  } else {
@@ -516,7 +516,7 @@ private:
516
516
  }
517
517
  }
518
518
  break;
519
-
519
+
520
520
  default:
521
521
  abort();
522
522
  }
@@ -571,7 +571,7 @@ public:
571
571
  ~FileBackedPipe() {
572
572
  delete[] memory.data;
573
573
  }
574
-
574
+
575
575
  bool resetable() const {
576
576
  //return dataState == IN_MEMORY;
577
577
  return true;
@@ -614,7 +614,7 @@ public:
614
614
  return (ssize_t) file.writtenSize
615
615
  - file.readOffset
616
616
  + file.writeBuffer.size();
617
-
617
+
618
618
  default:
619
619
  abort();
620
620
  }
@@ -83,17 +83,17 @@ class RemoteController: public MessageServer::Handler {
83
83
  private:
84
84
  struct SpecificContext: public MessageServer::ClientContext {
85
85
  };
86
-
86
+
87
87
  typedef MessageServer::CommonClientContext CommonClientContext;
88
-
88
+
89
89
  boost::shared_ptr<RequestHandler> requestHandler;
90
90
  PoolPtr pool;
91
-
92
-
91
+
92
+
93
93
  /*********************************************
94
94
  * Message handler methods
95
95
  *********************************************/
96
-
96
+
97
97
  void processDetachProcess(CommonClientContext &commonContext, SpecificContext *specificContext,
98
98
  const vector<string> &args)
99
99
  {
@@ -114,7 +114,7 @@ private:
114
114
  // TODO: implement this
115
115
  writeArrayMessage(commonContext.fd, "false", NULL);
116
116
  }
117
-
117
+
118
118
  bool processInspect(CommonClientContext &commonContext, SpecificContext *specificContext,
119
119
  const vector<string> &args)
120
120
  {
@@ -128,7 +128,7 @@ private:
128
128
  writeScalarMessage(commonContext.fd, pool->inspect(Pool::InspectOptions(options)));
129
129
  return true;
130
130
  }
131
-
131
+
132
132
  void processToXml(CommonClientContext &commonContext, SpecificContext *specificContext,
133
133
  const vector<string> &args)
134
134
  {
@@ -173,17 +173,17 @@ private:
173
173
  requestHandler->inspect(stream);
174
174
  writeScalarMessage(commonContext.fd, stream.str());
175
175
  }
176
-
176
+
177
177
  public:
178
178
  RemoteController(const boost::shared_ptr<RequestHandler> &requestHandler, const PoolPtr &pool) {
179
179
  this->requestHandler = requestHandler;
180
180
  this->pool = pool;
181
181
  }
182
-
182
+
183
183
  virtual MessageServer::ClientContextPtr newClient(CommonClientContext &commonContext) {
184
184
  return boost::make_shared<SpecificContext>();
185
185
  }
186
-
186
+
187
187
  virtual bool processMessage(CommonClientContext &commonContext,
188
188
  MessageServer::ClientContextPtr &_specificContext,
189
189
  const vector<string> &args)
@@ -219,12 +219,12 @@ public:
219
219
  class ExitHandler: public MessageServer::Handler {
220
220
  private:
221
221
  EventFd &exitEvent;
222
-
222
+
223
223
  public:
224
224
  ExitHandler(EventFd &_exitEvent)
225
225
  : exitEvent(_exitEvent)
226
226
  { }
227
-
227
+
228
228
  virtual bool processMessage(MessageServer::CommonClientContext &commonContext,
229
229
  MessageServer::ClientContextPtr &handlerSpecificContext,
230
230
  const vector<string> &args)
@@ -252,10 +252,10 @@ class Server {
252
252
  private:
253
253
  static const int MESSAGE_SERVER_THREAD_STACK_SIZE = 128 * 1024;
254
254
  static const int EVENT_LOOP_THREAD_STACK_SIZE = 256 * 1024;
255
-
255
+
256
256
  FileDescriptor feedbackFd;
257
257
  const AgentOptions &options;
258
-
258
+
259
259
  BackgroundEventLoop poolLoop;
260
260
  BackgroundEventLoop requestLoop;
261
261
 
@@ -264,6 +264,7 @@ private:
264
264
  ServerInstanceDir::GenerationPtr generation;
265
265
  UnionStation::CorePtr unionStationCore;
266
266
  RandomGeneratorPtr randomGenerator;
267
+ SpawnerConfigPtr spawnerConfig;
267
268
  SpawnerFactoryPtr spawnerFactory;
268
269
  PoolPtr pool;
269
270
  ev::sig sigquitWatcher;
@@ -275,7 +276,7 @@ private:
275
276
  boost::shared_ptr<oxt::thread> messageServerThread;
276
277
  boost::shared_ptr<oxt::thread> eventLoopThread;
277
278
  EventFd exitEvent;
278
-
279
+
279
280
  /**
280
281
  * Starts listening for client connections on this server's request socket.
281
282
  *
@@ -285,7 +286,7 @@ private:
285
286
  void startListening() {
286
287
  this_thread::disable_syscall_interruption dsi;
287
288
  requestSocket = createUnixServer(getRequestSocketFilename().c_str());
288
-
289
+
289
290
  int ret, e;
290
291
  do {
291
292
  ret = chmod(getRequestSocketFilename().c_str(), S_ISVTX |
@@ -334,7 +335,7 @@ private:
334
335
  }
335
336
  }
336
337
  }
337
-
338
+
338
339
  /**
339
340
  * Lowers this process's privilege to that of <em>username</em> and <em>groupname</em>.
340
341
  */
@@ -342,7 +343,7 @@ private:
342
343
  struct passwd *userEntry;
343
344
  gid_t gid;
344
345
  int e;
345
-
346
+
346
347
  userEntry = getpwnam(username.c_str());
347
348
  if (userEntry == NULL) {
348
349
  throw NonExistentUserException(string("Unable to lower Passenger "
@@ -355,7 +356,7 @@ private:
355
356
  "HelperAgent's privilege to that of user '") + username +
356
357
  "': user does not exist.");
357
358
  }
358
-
359
+
359
360
  if (initgroups(username.c_str(), userEntry->pw_gid) != 0) {
360
361
  e = errno;
361
362
  throw SystemException(string("Unable to lower Passenger HelperAgent's "
@@ -377,7 +378,7 @@ private:
377
378
 
378
379
  setenv("HOME", userEntry->pw_dir, 1);
379
380
  }
380
-
381
+
381
382
  void onSigquit(ev::sig &signal, int revents) {
382
383
  requestHandler->inspect(cerr);
383
384
  cerr.flush();
@@ -402,7 +403,7 @@ private:
402
403
  self->requestHandler->inspect(cerr);
403
404
  cerr << "\n";
404
405
  cerr.flush();
405
-
406
+
406
407
  cerr << "### Pool state (simple)\n";
407
408
  // Do not lock, the crash may occur within the pool.
408
409
  Pool::InspectOptions options;
@@ -420,7 +421,7 @@ private:
420
421
  cerr << oxt::thread::all_backtraces();
421
422
  cerr.flush();
422
423
  }
423
-
424
+
424
425
  public:
425
426
  Server(FileDescriptor feedbackFd, const AgentOptions &_options)
426
427
  : options(_options),
@@ -430,7 +431,7 @@ public:
430
431
  {
431
432
  TRACE_POINT();
432
433
  this->feedbackFd = feedbackFd;
433
-
434
+
434
435
  UPDATE_TRACE_POINT();
435
436
  generation = serverInstanceDir.getGeneration(options.generationNumber);
436
437
  startListening();
@@ -442,10 +443,10 @@ public:
442
443
  accountsDatabase->add("_web_server", options.exitPassword, false, Account::EXIT);
443
444
  messageServer = boost::make_shared<MessageServer>(
444
445
  parseUnixSocketAddress(options.adminSocketAddress), accountsDatabase);
445
-
446
+
446
447
  createFile(generation->getPath() + "/helper_agent.pid",
447
448
  toString(getpid()), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
448
-
449
+
449
450
  if (geteuid() == 0 && !options.userSwitching) {
450
451
  lowerPrivilege(options.defaultUser, options.defaultGroup);
451
452
  }
@@ -458,18 +459,18 @@ public:
458
459
  throw RuntimeException("Your random number device, /dev/urandom, appears to be broken. "
459
460
  "It doesn't seem to be returning random data. Please fix this.");
460
461
  }
461
-
462
+
462
463
  UPDATE_TRACE_POINT();
463
464
  unionStationCore = boost::make_shared<UnionStation::Core>(options.loggingAgentAddress,
464
465
  "logging", options.loggingAgentPassword);
465
- spawnerFactory = boost::make_shared<SpawnerFactory>(generation,
466
- boost::make_shared<SpawnerConfig>(resourceLocator, unionStationCore,
467
- randomGenerator));
466
+ spawnerConfig = boost::make_shared<SpawnerConfig>(resourceLocator, unionStationCore,
467
+ randomGenerator, &options);
468
+ spawnerFactory = boost::make_shared<SpawnerFactory>(generation, spawnerConfig);
468
469
  pool = boost::make_shared<Pool>(spawnerFactory, &options);
469
470
  pool->initialize();
470
471
  pool->setMax(options.maxPoolSize);
471
472
  pool->setMaxIdleTime(options.poolIdleTime * 1000000);
472
-
473
+
473
474
  requestHandler = boost::make_shared<RequestHandler>(requestLoop.safe,
474
475
  requestSocket, pool, options);
475
476
 
@@ -480,14 +481,14 @@ public:
480
481
  sigquitWatcher.set(SIGQUIT);
481
482
  sigquitWatcher.set<Server, &Server::onSigquit>(this);
482
483
  sigquitWatcher.start();
483
-
484
+
484
485
  UPDATE_TRACE_POINT();
485
486
  writeArrayMessage(feedbackFd,
486
487
  "initialized",
487
488
  getRequestSocketFilename().c_str(),
488
489
  messageServer->getSocketFilename().c_str(),
489
490
  NULL);
490
-
491
+
491
492
  boost::function<void ()> func = boost::bind(prestartWebApps,
492
493
  resourceLocator,
493
494
  options.defaultRubyCommand,
@@ -497,18 +498,18 @@ public:
497
498
  boost::bind(runAndPrintExceptions, func, true)
498
499
  ));
499
500
  }
500
-
501
+
501
502
  ~Server() {
502
503
  TRACE_POINT();
503
504
  this_thread::disable_syscall_interruption dsi;
504
505
  this_thread::disable_interruption di;
505
-
506
+
506
507
  P_DEBUG("Shutting down helper agent...");
507
508
  prestarterThread->interrupt_and_join();
508
509
  if (messageServerThread != NULL) {
509
510
  messageServerThread->interrupt_and_join();
510
511
  }
511
-
512
+
512
513
  messageServer.reset();
513
514
  P_DEBUG("Destroying application pool...");
514
515
  pool->destroy();
@@ -538,10 +539,10 @@ public:
538
539
  syscalls::unlink(options.requestSocketLink.c_str());
539
540
  }
540
541
  }
541
-
542
+
542
543
  P_TRACE(2, "All threads have been shut down.");
543
544
  }
544
-
545
+
545
546
  void mainLoop() {
546
547
  TRACE_POINT();
547
548
  boost::function<void ()> func;
@@ -551,7 +552,7 @@ public:
551
552
  boost::bind(runAndPrintExceptions, func, true),
552
553
  "MessageServer thread", MESSAGE_SERVER_THREAD_STACK_SIZE
553
554
  ));
554
-
555
+
555
556
  poolLoop.start("Pool event loop", 0);
556
557
  requestLoop.start("Request event loop", 0);
557
558
 
@@ -562,7 +563,7 @@ public:
562
563
  this_thread::disable_syscall_interruption dsi;
563
564
  fd_set fds;
564
565
  int largestFd;
565
-
566
+
566
567
  FD_ZERO(&fds);
567
568
  FD_SET(feedbackFd, &fds);
568
569
  FD_SET(exitEvent.fd(), &fds);
@@ -574,7 +575,7 @@ public:
574
575
  uninstallDiagnosticsDumper();
575
576
  throw SystemException("select() failed", e);
576
577
  }
577
-
578
+
578
579
  if (FD_ISSET(feedbackFd, &fds)) {
579
580
  /* If the watchdog has been killed then we'll kill all descendant
580
581
  * processes and exit. There's no point in keeping this helper
@@ -641,20 +642,20 @@ main(int argc, char *argv[]) {
641
642
 
642
643
  P_DEBUG("Starting PassengerHelperAgent...");
643
644
  MultiLibeio::init();
644
-
645
+
645
646
  try {
646
647
  UPDATE_TRACE_POINT();
647
648
  Server server(FileDescriptor(FEEDBACK_FD), *options);
648
649
  P_WARN("PassengerHelperAgent online, listening at unix:" <<
649
650
  server.getRequestSocketFilename());
650
-
651
+
651
652
  UPDATE_TRACE_POINT();
652
653
  server.mainLoop();
653
654
  } catch (const tracable_exception &e) {
654
655
  P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
655
656
  return 1;
656
657
  }
657
-
658
+
658
659
  MultiLibeio::shutdown();
659
660
  P_TRACE(2, "Helper agent exiting with code 0.");
660
661
  return 0;