passenger 5.0.10 → 5.0.11

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 (124) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +18 -0
  5. data/CONTRIBUTING.md +3 -3
  6. data/bin/passenger-status +12 -4
  7. data/build/agents.rb +45 -45
  8. data/build/apache2.rb +1 -1
  9. data/build/basics.rb +1 -1
  10. data/build/cxx_tests.rb +12 -12
  11. data/doc/CloudLicensingConfiguration.html +10 -10
  12. data/doc/CloudLicensingConfiguration.txt.md +10 -10
  13. data/doc/DebuggingAndStressTesting.md +3 -3
  14. data/doc/Design and Architecture.html +30 -30
  15. data/doc/Design and Architecture.txt +28 -28
  16. data/doc/ServerOptimizationGuide.html +3 -3
  17. data/doc/ServerOptimizationGuide.txt.md +3 -3
  18. data/doc/Users guide Apache.html +24 -12
  19. data/doc/Users guide Apache.txt +2 -2
  20. data/doc/Users guide Nginx.html +24 -12
  21. data/doc/Users guide Nginx.txt +2 -2
  22. data/doc/Users guide Standalone.html +18 -6
  23. data/doc/images/passenger_architecture.png +0 -0
  24. data/doc/images/passenger_architecture.svg +10 -9
  25. data/doc/images/{helper_agent_core_architecture.png → passenger_core_architecture.png} +0 -0
  26. data/doc/users_guide_snippets/environment_variables.txt +1 -1
  27. data/doc/users_guide_snippets/installation/verify_running_epilogue.txt +1 -1
  28. data/doc/users_guide_snippets/support_information.txt +1 -1
  29. data/doc/users_guide_snippets/tips.txt +2 -2
  30. data/doc/users_guide_snippets/under_the_hood/relationship_with_ruby.txt +1 -1
  31. data/ext/apache2/Bucket.h +5 -5
  32. data/ext/apache2/Configuration.cpp +1 -1
  33. data/ext/apache2/Configuration.hpp +2 -3
  34. data/ext/apache2/ConfigurationFields.hpp +3 -0
  35. data/ext/apache2/ConfigurationFields.hpp.erb +3 -0
  36. data/ext/apache2/Hooks.cpp +42 -34
  37. data/ext/common/Account.h +3 -3
  38. data/ext/common/AgentsStarter.cpp +7 -7
  39. data/ext/common/AgentsStarter.h +20 -20
  40. data/ext/common/ApplicationPool2/Options.h +12 -12
  41. data/ext/common/Constants.h +10 -8
  42. data/ext/common/Logging.cpp +22 -1
  43. data/ext/common/Logging.h +19 -2
  44. data/ext/common/ServerKit/AcceptLoadBalancer.h +3 -3
  45. data/ext/common/ServerKit/Server.h +24 -0
  46. data/ext/common/UnionStation/Connection.h +1 -1
  47. data/ext/common/UnionStation/Core.h +21 -21
  48. data/ext/common/UnionStation/Transaction.h +3 -3
  49. data/ext/common/Utils.cpp +2 -2
  50. data/ext/common/Utils/IOUtils.cpp +5 -1
  51. data/ext/common/{agents → agent}/ApiServerUtils.h +3 -3
  52. data/ext/common/{agents → agent}/Base.cpp +2 -2
  53. data/ext/common/{agents → agent}/Base.h +0 -0
  54. data/ext/common/{agents/HelperAgent → agent/Core}/ApiServer.h +33 -9
  55. data/ext/common/{agents/HelperAgent → agent/Core}/Main.cpp +60 -59
  56. data/ext/common/{agents/HelperAgent → agent/Core}/OptionParser.h +32 -25
  57. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler.h +17 -17
  58. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/AppResponse.h +0 -0
  59. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/BufferBody.cpp +0 -0
  60. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/CheckoutSession.cpp +0 -0
  61. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Client.h +2 -2
  62. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/ForwardResponse.cpp +0 -0
  63. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Hooks.cpp +0 -0
  64. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/InitRequest.cpp +4 -3
  65. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Request.h +1 -1
  66. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/SendRequest.cpp +0 -0
  67. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/TurboCaching.h +1 -1
  68. data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Utils.cpp +0 -0
  69. data/ext/common/{agents/HelperAgent → agent/Core}/ResponseCache.h +0 -0
  70. data/ext/common/{agents → agent}/Main.cpp +9 -9
  71. data/ext/common/{agents → agent}/SpawnPreparer/Main.cpp +0 -0
  72. data/ext/common/{agents/HelperAgent/SystemMetricsTool.cpp → agent/SystemMetrics/Main.cpp} +0 -0
  73. data/ext/common/{agents → agent}/TempDirToucher/Main.cpp +0 -0
  74. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/ApiServer.h +7 -7
  75. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/DataStoreId.h +0 -0
  76. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/FilterSupport.cpp +0 -0
  77. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/FilterSupport.h +0 -0
  78. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/LoggingServer.h +4 -4
  79. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/Main.cpp +45 -45
  80. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/OptionParser.h +20 -20
  81. data/ext/common/{agents/LoggingAgent → agent/UstRouter}/RemoteSender.h +0 -0
  82. data/ext/common/{agents → agent}/Watchdog/AgentWatcher.cpp +0 -0
  83. data/ext/common/{agents → agent}/Watchdog/ApiServer.h +1 -1
  84. data/ext/common/{agents/Watchdog/HelperAgentWatcher.cpp → agent/Watchdog/CoreWatcher.cpp} +14 -10
  85. data/ext/common/{agents → agent}/Watchdog/InstanceDirToucher.cpp +0 -0
  86. data/ext/common/{agents → agent}/Watchdog/Main.cpp +131 -75
  87. data/ext/common/{agents/Watchdog/LoggingAgentWatcher.cpp → agent/Watchdog/UstRouterWatcher.cpp} +13 -9
  88. data/ext/nginx/CacheLocationConfig.c +11 -6
  89. data/ext/nginx/CacheLocationConfig.c.erb +11 -6
  90. data/ext/nginx/Configuration.c +22 -7
  91. data/ext/nginx/Configuration.h +1 -19
  92. data/ext/nginx/ConfigurationFields.h +19 -0
  93. data/ext/nginx/ConfigurationFields.h.erb +19 -0
  94. data/ext/nginx/ContentHandler.c +33 -33
  95. data/ext/nginx/CreateLocationConfig.c +3 -1
  96. data/ext/nginx/CreateLocationConfig.c.erb +3 -1
  97. data/ext/nginx/MergeLocationConfig.c +8 -4
  98. data/ext/nginx/MergeLocationConfig.c.erb +7 -3
  99. data/ext/nginx/ngx_http_passenger_module.c +33 -42
  100. data/helper-scripts/backtrace-sanitizer.rb +2 -2
  101. data/lib/phusion_passenger.rb +1 -1
  102. data/lib/phusion_passenger/admin_tools/instance.rb +2 -2
  103. data/lib/phusion_passenger/admin_tools/instance_registry.rb +7 -3
  104. data/lib/phusion_passenger/common_library.rb +8 -8
  105. data/lib/phusion_passenger/config/about_command.rb +1 -1
  106. data/lib/phusion_passenger/config/api_call_command.rb +3 -3
  107. data/lib/phusion_passenger/config/installation_utils.rb +34 -21
  108. data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
  109. data/lib/phusion_passenger/config/restart_app_command.rb +18 -4
  110. data/lib/phusion_passenger/constants.rb +7 -5
  111. data/lib/phusion_passenger/loader_shared_helpers.rb +2 -6
  112. data/lib/phusion_passenger/message_client.rb +8 -8
  113. data/lib/phusion_passenger/platform_info/ruby.rb +1 -2
  114. data/lib/phusion_passenger/preloader_shared_helpers.rb +1 -1
  115. data/lib/phusion_passenger/request_handler.rb +3 -2
  116. data/lib/phusion_passenger/request_handler/thread_handler.rb +4 -4
  117. data/lib/phusion_passenger/standalone/start_command.rb +13 -3
  118. data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +2 -1
  119. data/lib/phusion_passenger/union_station/core.rb +18 -18
  120. data/lib/phusion_passenger/union_station/transaction.rb +5 -5
  121. data/resources/oss-binaries.phusionpassenger.com.crt +0 -84
  122. data/resources/templates/standalone/config.erb +1 -0
  123. metadata +40 -40
  124. metadata.gz.asc +7 -7
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010 Phusion
3
+ * Copyright (c) 2010-2015 Phusion
4
4
  *
5
5
  * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
6
  *
@@ -62,7 +62,7 @@ public:
62
62
  ALL = ~0,
63
63
  NONE = 0,
64
64
 
65
- // HelperAgent ApplicationPool rights.
65
+ // Passenger core ApplicationPool rights.
66
66
  CLEAR = 1 << 0,
67
67
  DETACH = 1 << 1,
68
68
  SET_PARAMETERS = 1 << 2,
@@ -70,7 +70,7 @@ public:
70
70
  INSPECT_BASIC_INFO = 1 << 4,
71
71
  INSPECT_SENSITIVE_INFO = 1 << 5,
72
72
 
73
- // HelperAgent admin rights.
73
+ // Passenger core admin rights.
74
74
  INSPECT_REQUESTS = 1 << 8,
75
75
  INSPECT_BACKTRACES = 1 << 9,
76
76
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2014 Phusion
3
+ * Copyright (c) 2010-2015 Phusion
4
4
  *
5
5
  * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
6
  *
@@ -137,21 +137,21 @@ pp_agents_starter_start(PP_AgentsStarter *as,
137
137
  }
138
138
 
139
139
  const char *
140
- pp_agents_starter_get_server_address(PP_AgentsStarter *as, unsigned int *size) {
140
+ pp_agents_starter_get_core_address(PP_AgentsStarter *as, unsigned int *size) {
141
141
  Passenger::AgentsStarter *agentsStarter = (Passenger::AgentsStarter *) as;
142
142
  if (size != NULL) {
143
- *size = agentsStarter->getServerAddress().size();
143
+ *size = agentsStarter->getCoreAddress().size();
144
144
  }
145
- return agentsStarter->getServerAddress().c_str();
145
+ return agentsStarter->getCoreAddress().c_str();
146
146
  }
147
147
 
148
148
  const char *
149
- pp_agents_starter_get_server_password(PP_AgentsStarter *as, unsigned int *size) {
149
+ pp_agents_starter_get_core_password(PP_AgentsStarter *as, unsigned int *size) {
150
150
  Passenger::AgentsStarter *agentsStarter = (Passenger::AgentsStarter *) as;
151
151
  if (size != NULL) {
152
- *size = agentsStarter->getServerPassword().size();
152
+ *size = agentsStarter->getCorePassword().size();
153
153
  }
154
- return agentsStarter->getServerPassword().c_str();
154
+ return agentsStarter->getCorePassword().c_str();
155
155
  }
156
156
 
157
157
  const char *
@@ -72,8 +72,8 @@ int pp_agents_starter_start(PP_AgentsStarter *as,
72
72
  const PP_AfterForkCallback afterFork,
73
73
  void *callbackArgument,
74
74
  char **errorMessage);
75
- const char *pp_agents_starter_get_server_address(PP_AgentsStarter *as, unsigned int *size);
76
- const char *pp_agents_starter_get_server_password(PP_AgentsStarter *as, unsigned int *size);
75
+ const char *pp_agents_starter_get_core_address(PP_AgentsStarter *as, unsigned int *size);
76
+ const char *pp_agents_starter_get_core_password(PP_AgentsStarter *as, unsigned int *size);
77
77
  const char *pp_agents_starter_get_instance_dir(PP_AgentsStarter *as, unsigned int *size);
78
78
  pid_t pp_agents_starter_get_pid(PP_AgentsStarter *as);
79
79
  void pp_agents_starter_detach(PP_AgentsStarter *as);
@@ -130,15 +130,15 @@ private:
130
130
  /** The watchdog's feedback file descriptor. */
131
131
  FileDescriptor feedbackFd;
132
132
 
133
- /** The address on which the Phusion Passenger HTTP server listens, and the
133
+ /** The address on which the Passenger core listens for HTTP requests, and the
134
134
  * corresponding password.
135
135
  */
136
- string serverAddress;
137
- string serverPassword;
136
+ string coreAddress;
137
+ string corePassword;
138
138
 
139
- /** The logging agent's socket address and its password. */
140
- string loggingAgentAddress;
141
- string loggingAgentPassword;
139
+ /** The UstRouter's socket address and its password. */
140
+ string ustRouterAddress;
141
+ string ustRouterPassword;
142
142
 
143
143
  string instanceDir;
144
144
 
@@ -291,20 +291,20 @@ public:
291
291
 
292
292
  // The 'const string &' here is on purpose. The C getter functions
293
293
  // return the string pointer directly.
294
- const string &getServerAddress() const {
295
- return serverAddress;
294
+ const string &getCoreAddress() const {
295
+ return coreAddress;
296
296
  }
297
297
 
298
- const string &getServerPassword() const {
299
- return serverPassword;
298
+ const string &getCorePassword() const {
299
+ return corePassword;
300
300
  }
301
301
 
302
- const string &getLoggingAgentAddress() const {
303
- return loggingAgentAddress;
302
+ const string &getUstRouterAddress() const {
303
+ return ustRouterAddress;
304
304
  }
305
305
 
306
- const string &getLoggingAgentPassword() const {
307
- return loggingAgentPassword;
306
+ const string &getUstRouterPassword() const {
307
+ return ustRouterPassword;
308
308
  }
309
309
 
310
310
  const string &getInstanceDir() const {
@@ -475,11 +475,11 @@ public:
475
475
 
476
476
  this->pid = pid;
477
477
  this->feedbackFd = feedbackFd;
478
- serverAddress = info.get("server_address");
479
- serverPassword = info.get("server_password");
478
+ coreAddress = info.get("core_address");
479
+ corePassword = info.get("core_password");
480
480
  instanceDir = info.get("instance_dir");
481
- loggingAgentAddress = info.get("logging_agent_address");
482
- loggingAgentPassword = info.get("logging_agent_password");
481
+ ustRouterAddress = info.get("ust_router_address");
482
+ ustRouterPassword = info.get("ust_router_password");
483
483
  guard.clear();
484
484
  } else if (args[0] == "Watchdog startup error") {
485
485
  killProcessGroupAndWait(&pid, 5000);
@@ -108,9 +108,9 @@ private:
108
108
  result.push_back(&options.meteorAppSettings);
109
109
 
110
110
  result.push_back(&options.environmentVariables);
111
- result.push_back(&options.loggingAgentAddress);
112
- result.push_back(&options.loggingAgentUsername);
113
- result.push_back(&options.loggingAgentPassword);
111
+ result.push_back(&options.ustRouterAddress);
112
+ result.push_back(&options.ustRouterUsername);
113
+ result.push_back(&options.ustRouterPassword);
114
114
  result.push_back(&options.apiKey);
115
115
  result.push_back(&options.hostName);
116
116
  result.push_back(&options.uri);
@@ -303,13 +303,13 @@ public:
303
303
  * It does *not* necessarily result in a request logging data to Union Station.
304
304
  * That depends on whether the `transaction` member is set.
305
305
  *
306
- * If this is set to true, then 'loggingAgentAddress', 'loggingAgentUsername'
307
- * and 'loggingAgentPassword' must be non-empty.
306
+ * If this is set to true, then 'ustRouterAddress', 'ustRouterUsername'
307
+ * and 'ustRouterPassword' must be non-empty.
308
308
  */
309
309
  bool analytics;
310
- StaticString loggingAgentAddress;
311
- StaticString loggingAgentUsername;
312
- StaticString loggingAgentPassword;
310
+ StaticString ustRouterAddress;
311
+ StaticString ustRouterUsername;
312
+ StaticString ustRouterPassword;
313
313
 
314
314
  /**
315
315
  * Whether Spawner should raise an internal error when spawning. Used
@@ -597,9 +597,9 @@ public:
597
597
  appendKeyValue (vec, "python", python);
598
598
  appendKeyValue (vec, "nodejs", nodejs);
599
599
  appendKeyValue (vec, "meteor_app_settings", meteorAppSettings);
600
- appendKeyValue (vec, "logging_agent_address", loggingAgentAddress);
601
- appendKeyValue (vec, "logging_agent_username", loggingAgentUsername);
602
- appendKeyValue (vec, "logging_agent_password", loggingAgentPassword);
600
+ appendKeyValue (vec, "ust_router_address", ustRouterAddress);
601
+ appendKeyValue (vec, "ust_router_username", ustRouterUsername);
602
+ appendKeyValue (vec, "ust_router_password", ustRouterPassword);
603
603
  appendKeyValue4(vec, "debugger", debugger);
604
604
  appendKeyValue4(vec, "analytics", analytics);
605
605
 
@@ -683,7 +683,7 @@ public:
683
683
 
684
684
  unsigned long getMaxPreloaderIdleTime() const {
685
685
  if (maxPreloaderIdleTime == -1) {
686
- return 5 * 60;
686
+ return DEFAULT_MAX_PRELOADER_IDLE_TIME;
687
687
  } else {
688
688
  return maxPreloaderIdleTime;
689
689
  }
@@ -64,14 +64,12 @@
64
64
 
65
65
  #define DEFAULT_HTTP_SERVER_LISTEN_ADDRESS "tcp://127.0.0.1:3000"
66
66
 
67
- #define DEFAULT_LOGGING_AGENT_API_LISTEN_ADDRESS "tcp://127.0.0.1:9345"
68
-
69
- #define DEFAULT_LOGGING_AGENT_LISTEN_ADDRESS "tcp://127.0.0.1:9344"
70
-
71
67
  #define DEFAULT_LOG_LEVEL 3
72
68
 
73
69
  #define DEFAULT_MAX_POOL_SIZE 6
74
70
 
71
+ #define DEFAULT_MAX_PRELOADER_IDLE_TIME 300
72
+
75
73
  #define DEFAULT_MBUF_CHUNK_SIZE 512
76
74
 
77
75
  #define DEFAULT_NODEJS "node"
@@ -96,6 +94,10 @@
96
94
 
97
95
  #define DEFAULT_UNION_STATION_GATEWAY_PORT 443
98
96
 
97
+ #define DEFAULT_UST_ROUTER_API_LISTEN_ADDRESS "tcp://127.0.0.1:9345"
98
+
99
+ #define DEFAULT_UST_ROUTER_LISTEN_ADDRESS "tcp://127.0.0.1:9344"
100
+
99
101
  #define DEFAULT_WEB_APP_USER "nobody"
100
102
 
101
103
  #define ENTERPRISE_URL "https://www.phusionpassenger.com/enterprise"
@@ -122,7 +124,7 @@
122
124
 
123
125
  #define PASSENGER_DEFAULT_USER "nobody"
124
126
 
125
- #define PASSENGER_VERSION "5.0.10"
127
+ #define PASSENGER_VERSION "5.0.11"
126
128
 
127
129
  #define POOL_HELPER_THREAD_STACK_SIZE 262144
128
130
 
@@ -142,9 +144,9 @@
142
144
 
143
145
  #define SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION 2
144
146
 
145
- #define SERVER_INSTANCE_DIR_STRUCTURE_MINOR_VERSION 1
147
+ #define SERVER_INSTANCE_DIR_STRUCTURE_MINOR_VERSION 3
146
148
 
147
- #define SERVER_INSTANCE_DIR_STRUCTURE_MIN_SUPPORTED_MINOR_VERSION 0
149
+ #define SERVER_INSTANCE_DIR_STRUCTURE_MIN_SUPPORTED_MINOR_VERSION 3
148
150
 
149
151
  #define SERVER_KIT_MAX_SERVER_ENDPOINTS 4
150
152
 
@@ -154,7 +156,7 @@
154
156
 
155
157
  #define STANDALONE_DOC_URL "https://www.phusionpassenger.com/documentation/Users%20guide%20Standalone.html"
156
158
 
157
- #define STANDALONE_NGINX_CONFIGURE_OPTIONS "--with-cc-opt='-Wno-error' --without-http_fastcgi_module --without-http_scgi_module --without-http_uwsgi_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module"
159
+ #define STANDALONE_NGINX_CONFIGURE_OPTIONS "--with-cc-opt='-Wno-error' --without-http_fastcgi_module --without-http_scgi_module --without-http_uwsgi_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module"
158
160
 
159
161
  #define SUPPORT_URL "https://www.phusionpassenger.com/documentation_and_support"
160
162
 
@@ -44,6 +44,7 @@ static bool printAppOutputAsDebuggingMessages = false;
44
44
 
45
45
  static boost::mutex logFileMutex;
46
46
  static string logFile;
47
+ static int logFd = STDERR_FILENO;
47
48
 
48
49
  static int fileDescriptorLog = -1;
49
50
  static string fileDescriptorLogFile;
@@ -85,6 +86,26 @@ setLogFileWithFd(const string &path, int fd) {
85
86
  logFile = path;
86
87
  }
87
88
 
89
+ bool
90
+ setLogFileWithoutRedirectingStderr(const string &path, int *errcode) {
91
+ int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_APPEND, 0644);
92
+ if (fd != -1) {
93
+ int oldLogFd = logFd;
94
+ logFd = fd;
95
+ if (oldLogFd != STDERR_FILENO) {
96
+ close(oldLogFd);
97
+ }
98
+ boost::lock_guard<boost::mutex> l(logFileMutex);
99
+ logFile = path;
100
+ return true;
101
+ } else {
102
+ if (errcode != NULL) {
103
+ *errcode = errno;
104
+ }
105
+ return false;
106
+ }
107
+ }
108
+
88
109
  bool
89
110
  hasFileDescriptorLogFile() {
90
111
  return fileDescriptorLog != -1;
@@ -195,7 +216,7 @@ writeExactWithoutOXT(int fd, const char *str, unsigned int size) {
195
216
 
196
217
  void
197
218
  _writeLogEntry(const char *str, unsigned int size) {
198
- writeExactWithoutOXT(STDERR_FILENO, str, size);
219
+ writeExactWithoutOXT(logFd, str, size);
199
220
  }
200
221
 
201
222
  void
@@ -84,14 +84,14 @@ void setLogLevel(int value);
84
84
  * Returns the general log file that we're using, or the empty string
85
85
  * if we're not using a log file.
86
86
  *
87
- * This method is NOT thread-safe.
87
+ * This method is thread-safe.
88
88
  */
89
89
  string getLogFile();
90
90
 
91
91
  /**
92
92
  * Sets the general log file. This method is thread-safe.
93
93
  * Returns whether the new log file can be opened. If not,
94
- * errcode (if non-NULL) is set to the relevant filesystem
94
+ * `errcode` (if non-NULL) is set to the relevant filesystem
95
95
  * error code.
96
96
  */
97
97
  bool setLogFile(const string &path, int *errcode = NULL);
@@ -102,6 +102,23 @@ bool setLogFile(const string &path, int *errcode = NULL);
102
102
  */
103
103
  void setLogFileWithFd(const string &path, int fd);
104
104
 
105
+ /**
106
+ * Sets the general log file. Unlike `setLogFile()` and `setLogFileWithFd()`,
107
+ * this method does not redirect stderr to that file. This is useful in
108
+ * e.g. the Apache module where redirecting stderr is not safe because it
109
+ * would affect all the other Apache modules too.
110
+ *
111
+ * Returns whether the new log file can be opened. If not,
112
+ * `errcode` (if non-NULL) is set to the relevant filesystem
113
+ * error code.
114
+ *
115
+ * WARNING:
116
+ * This method is NOT thread-safe.
117
+ * Once you have called this method, you may not call `setLogFile()`
118
+ * or `setLogFileWithFd()`.
119
+ */
120
+ bool setLogFileWithoutRedirectingStderr(const string &path, int *errcode = NULL);
121
+
105
122
  /**
106
123
  * Returns whether we're using a separate log file for logging file
107
124
  * descriptor opening and closing.
@@ -74,9 +74,9 @@ using namespace boost;
74
74
  * accepts are distributed to all registered Server objects, in a
75
75
  * round-robin manner.
76
76
  *
77
- * Inside the "PassengerAgent server", we activate AcceptLoadBalancer
78
- * only if `server_threads > 1`, which is often the case because
79
- * `server_threads` defaults to the number of CPU cores.
77
+ * Inside the "PassengerAgent core", we activate AcceptLoadBalancer
78
+ * only if `core_threads > 1`, which is often the case because
79
+ * `core_threads` defaults to the number of CPU cores.
80
80
  */
81
81
  template<typename Server>
82
82
  class AcceptLoadBalancer {
@@ -807,6 +807,30 @@ public:
807
807
  return NULL;
808
808
  }
809
809
 
810
+ bool clientOnUnixDomainSocket(Client *client) {
811
+ union {
812
+ struct sockaddr genericAddress;
813
+ struct sockaddr_un unixAddress;
814
+ struct sockaddr_in inetAddress;
815
+ } addr;
816
+ socklen_t len = sizeof(addr);
817
+ int ret;
818
+
819
+ do {
820
+ ret = getsockname(client->getFd(), &addr.genericAddress, &len);
821
+ } while (ret == -1 && errno == EINTR);
822
+ if (ret == -1) {
823
+ int e = errno;
824
+ throw SystemException("Unable to autodetect socket type (getsockname() failed)", e);
825
+ } else {
826
+ #ifdef AF_UNIX
827
+ return addr.genericAddress.sa_family == AF_UNIX;
828
+ #else
829
+ return addr.genericAddress.sa_family == AF_LOCAL;
830
+ #endif
831
+ }
832
+ }
833
+
810
834
  /** Increase client reference count. */
811
835
  void refClient(Client *client, const char *file, unsigned int line) {
812
836
  int oldRefcount = client->refcount.fetch_add(1, boost::memory_order_relaxed);
@@ -83,7 +83,7 @@ public:
83
83
 
84
84
 
85
85
  /**
86
- * Represents a connection to the logging server.
86
+ * Represents a connection to the UstRouter.
87
87
  * All access to the file descriptor must be synchronized through the syncher.
88
88
  * You can use the ConnectionLock to do that.
89
89
  */
@@ -145,17 +145,17 @@ private:
145
145
  fd = connectToServer(serverAddress, __FILE__, __LINE__);
146
146
  FdGuard guard(fd, NULL, 0, true);
147
147
 
148
- P_LOG_FILE_DESCRIPTOR_PURPOSE(fd, "Connection to " AGENT_EXE " logger");
148
+ P_LOG_FILE_DESCRIPTOR_PURPOSE(fd, "Connection to " SHORT_PROGRAM_NAME " UstRouter");
149
149
 
150
150
  // Handshake: process protocol version number.
151
151
  if (!readArrayMessage(fd, args, &timeout)) {
152
- throw IOException("The logging agent closed the connection before sending a version identifier.");
152
+ throw IOException("The UstRouter closed the connection before sending a version identifier.");
153
153
  }
154
154
  if (args.size() != 2 || args[0] != "version") {
155
- throw IOException("The logging agent server didn't sent a valid version identifier.");
155
+ throw IOException("The UstRouter server didn't sent a valid version identifier.");
156
156
  }
157
157
  if (args[1] != "1") {
158
- string message = "Unsupported logging agent protocol version " +
158
+ string message = "Unsupported UstRouter protocol version " +
159
159
  args[1] + ".";
160
160
  throw IOException(message);
161
161
  }
@@ -167,24 +167,24 @@ private:
167
167
 
168
168
  UPDATE_TRACE_POINT();
169
169
  if (!readArrayMessage(fd, args, &timeout)) {
170
- throw IOException("The logging agent did not send an authentication response.");
170
+ throw IOException("The UstRouter did not send an authentication response.");
171
171
  } else if (args.size() != 1) {
172
- throw IOException("The authentication response that the logging agent sent is not valid.");
172
+ throw IOException("The authentication response that the UstRouter sent is not valid.");
173
173
  } else if (args[0] != "ok") {
174
- throw SecurityException("The logging agent server denied authentication: " + args[0]);
174
+ throw SecurityException("The UstRouter server denied authentication: " + args[0]);
175
175
  }
176
176
 
177
177
  // Initialize session.
178
178
  UPDATE_TRACE_POINT();
179
179
  writeArrayMessage(fd, &timeout, "init", nodeName.c_str(), NULL);
180
180
  if (!readArrayMessage(fd, args, &timeout)) {
181
- throw SystemException("Cannot connect to logging server", ECONNREFUSED);
181
+ throw SystemException("Cannot connect to the UstRouter", ECONNREFUSED);
182
182
  } else if (args.size() != 1) {
183
- throw IOException("Logging server returned an invalid reply for the 'init' command");
183
+ throw IOException("UstRouter returned an invalid reply for the 'init' command");
184
184
  } else if (args[0] == "server shutting down") {
185
185
  throw SystemException("Cannot connect to server", ECONNREFUSED);
186
186
  } else if (args[0] != "ok") {
187
- throw IOException("Logging server returned an invalid reply for the 'init' command");
187
+ throw IOException("UstRouter returned an invalid reply for the 'init' command");
188
188
  }
189
189
 
190
190
  ConnectionPtr connection = boost::make_shared<Connection>(fd);
@@ -226,13 +226,13 @@ public:
226
226
  }
227
227
 
228
228
  l.unlock();
229
- P_TRACE(3, "Creating new connection with logging agent");
229
+ P_TRACE(3, "Creating new connection with UstRouter");
230
230
  ConnectionPtr connection;
231
231
  try {
232
232
  connection = createNewConnection();
233
233
  } catch (const TimeoutException &) {
234
234
  l.lock();
235
- P_WARN("Timeout trying to connect to the logging agent at " << serverAddress << "; " <<
235
+ P_WARN("Timeout trying to connect to the UstRouter at " << serverAddress << "; " <<
236
236
  "will reconnect in " << reconnectTimeout / 1000000 << " second(s).");
237
237
  nextReconnectTime = SystemTime::getUsec() + reconnectTimeout;
238
238
  return ConnectionPtr();
@@ -240,7 +240,7 @@ public:
240
240
  l.lock();
241
241
  nextReconnectTime = SystemTime::getUsec() + reconnectTimeout;
242
242
  if (instanceof<IOException>(e) || instanceof<SystemException>(e)) {
243
- P_WARN("Cannot connect to the logging agent at " << serverAddress <<
243
+ P_WARN("Cannot connect to the UstRouter at " << serverAddress <<
244
244
  " (" << e.what() << "); will reconnect in " <<
245
245
  reconnectTimeout / 1000000 << " second(s).");
246
246
  return ConnectionPtr();
@@ -285,7 +285,7 @@ public:
285
285
  vector<string> args;
286
286
  if (!readArrayMessage(connection->fd, args, &timeout)) {
287
287
  boost::lock_guard<boost::mutex> l(syncher);
288
- P_WARN("The logging agent at " << serverAddress <<
288
+ P_WARN("The UstRouter at " << serverAddress <<
289
289
  " closed the connection (no error message given);" <<
290
290
  " will reconnect in " << reconnectTimeout / 1000000 <<
291
291
  " second(s).");
@@ -293,7 +293,7 @@ public:
293
293
  return false;
294
294
  } else if (args.size() == 2 && args[0] == "error") {
295
295
  boost::lock_guard<boost::mutex> l(syncher);
296
- P_WARN("The logging agent at " << serverAddress <<
296
+ P_WARN("The UstRouter at " << serverAddress <<
297
297
  " closed the connection (error message: " << args[1] <<
298
298
  "); will reconnect in " << reconnectTimeout / 1000000 <<
299
299
  " second(s).");
@@ -301,7 +301,7 @@ public:
301
301
  return false;
302
302
  } else if (args.empty() || args[0] != "ok") {
303
303
  boost::lock_guard<boost::mutex> l(syncher);
304
- P_WARN("The logging agent at " << serverAddress <<
304
+ P_WARN("The UstRouter at " << serverAddress <<
305
305
  " sent an unexpected reply;" <<
306
306
  " will reconnect in " << reconnectTimeout / 1000000 <<
307
307
  " second(s).");
@@ -315,7 +315,7 @@ public:
315
315
 
316
316
  } catch (const TimeoutException &) {
317
317
  boost::lock_guard<boost::mutex> l(syncher);
318
- P_WARN("Timeout trying to communicate with the logging agent at " << serverAddress << "; " <<
318
+ P_WARN("Timeout trying to communicate with the UstRouter at " << serverAddress << "; " <<
319
319
  "will reconnect in " << reconnectTimeout / 1000000 << " second(s).");
320
320
  nextReconnectTime = SystemTime::getUsec() + reconnectTimeout;
321
321
  return false;
@@ -329,12 +329,12 @@ public:
329
329
  gotErrorResponse = connection->disconnect(errorResponse);
330
330
  boost::lock_guard<boost::mutex> l(syncher);
331
331
  if (gotErrorResponse) {
332
- P_WARN("The logging agent at " << serverAddress <<
332
+ P_WARN("The UstRouter at " << serverAddress <<
333
333
  " closed the connection (error message: " << errorResponse <<
334
334
  "); will reconnect in " << reconnectTimeout / 1000000 <<
335
335
  " second(s).");
336
336
  } else {
337
- P_WARN("The logging agent at " << serverAddress <<
337
+ P_WARN("The UstRouter at " << serverAddress <<
338
338
  " closed the connection (no error message given);" <<
339
339
  " will reconnect in " << reconnectTimeout / 1000000 <<
340
340
  " second(s).");
@@ -380,7 +380,7 @@ public:
380
380
  };
381
381
  unsigned int nparams = sizeof(params) / sizeof(StaticString);
382
382
 
383
- // Get a connection to the logging server.
383
+ // Get a connection to the UstRouter.
384
384
  ConnectionPtr connection = checkoutConnection();
385
385
  if (connection == NULL) {
386
386
  P_TRACE(2, "Created NULL Union Station transaction: group=" << groupName <<
@@ -440,7 +440,7 @@ public:
440
440
  };
441
441
  unsigned int nparams = sizeof(params) / sizeof(StaticString);
442
442
 
443
- // Get a connection to the logging server.
443
+ // Get a connection to the UstRouter.
444
444
  ConnectionPtr connection = checkoutConnection();
445
445
  if (connection == NULL) {
446
446
  return createNullTransaction();