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.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +36 -2
- data/.travis.yml +1 -1
- data/CHANGELOG +16 -0
- data/Rakefile +0 -1
- data/build/apache2.rb +4 -4
- data/build/common_library.rb +18 -18
- data/build/cplusplus_support.rb +2 -2
- data/build/documentation.rb +1 -1
- data/build/integration_tests.rb +12 -4
- data/build/misc.rb +12 -7
- data/build/packaging.rb +14 -14
- data/build/preprocessor.rb +10 -10
- data/build/rake_extensions.rb +11 -11
- data/build/ruby_extension.rb +2 -2
- data/dev/ci/inituidgid +24 -0
- data/dev/ci/run_jenkins.sh +57 -0
- data/dev/ci/run_rpm_tests.sh +77 -0
- data/dev/{run_travis.sh → ci/run_travis.sh} +60 -4
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/users_guide_snippets/environment_variables.txt +0 -2
- data/doc/users_guide_snippets/tips.txt +20 -1
- data/ext/apache2/Bucket.cpp +18 -18
- data/ext/apache2/Bucket.h +4 -4
- data/ext/apache2/Configuration.cpp +7 -7
- data/ext/apache2/Configuration.hpp +43 -43
- data/ext/apache2/DirectoryMapper.h +5 -5
- data/ext/apache2/Hooks.cpp +142 -142
- data/ext/apache2/MergeDirConfig.cpp +40 -40
- data/ext/common/Account.h +17 -17
- data/ext/common/AccountsDatabase.h +9 -9
- data/ext/common/AgentsStarter.cpp +2 -2
- data/ext/common/AgentsStarter.h +40 -40
- data/ext/common/ApplicationPool2/Common.h +10 -6
- data/ext/common/ApplicationPool2/ComponentInfo.h +2 -2
- data/ext/common/ApplicationPool2/DirectSpawner.h +17 -17
- data/ext/common/ApplicationPool2/DummySpawner.h +5 -5
- data/ext/common/ApplicationPool2/Group.h +54 -38
- data/ext/common/ApplicationPool2/Implementation.cpp +76 -49
- data/ext/common/ApplicationPool2/Options.h +98 -91
- data/ext/common/ApplicationPool2/Pool.h +70 -69
- data/ext/common/ApplicationPool2/Process.h +21 -21
- data/ext/common/ApplicationPool2/Session.h +11 -11
- data/ext/common/ApplicationPool2/SmartSpawner.h +60 -60
- data/ext/common/ApplicationPool2/Socket.h +19 -19
- data/ext/common/ApplicationPool2/Spawner.h +64 -72
- data/ext/common/ApplicationPool2/SpawnerFactory.h +4 -4
- data/ext/common/ApplicationPool2/SuperGroup.h +41 -41
- data/ext/common/BackgroundEventLoop.cpp +1 -1
- data/ext/common/BackgroundEventLoop.h +2 -2
- data/ext/common/Constants.h +1 -1
- data/ext/common/EventedBufferedInput.h +5 -5
- data/ext/common/EventedClient.h +51 -51
- data/ext/common/EventedMessageServer.h +39 -39
- data/ext/common/EventedServer.h +32 -32
- data/ext/common/Exceptions.h +23 -23
- data/ext/common/FileDescriptor.h +18 -18
- data/ext/common/Logging.cpp +1 -1
- data/ext/common/MessageClient.h +27 -27
- data/ext/common/MessageReadersWriters.h +79 -79
- data/ext/common/MessageServer.h +59 -59
- data/ext/common/RandomGenerator.h +12 -12
- data/ext/common/ResourceLocator.h +8 -8
- data/ext/common/SafeLibev.h +54 -25
- data/ext/common/ServerInstanceDir.h +31 -31
- data/ext/common/StaticString.h +50 -48
- data/ext/common/Utils.cpp +73 -78
- data/ext/common/Utils.h +6 -6
- data/ext/common/Utils/Base64.cpp +3 -3
- data/ext/common/Utils/Base64.h +7 -7
- data/ext/common/Utils/BlockingQueue.h +9 -9
- data/ext/common/Utils/BufferedIO.h +17 -17
- data/ext/common/Utils/CachedFileStat.hpp +16 -16
- data/ext/common/Utils/Dechunker.h +25 -25
- data/ext/common/Utils/FileChangeChecker.h +10 -10
- data/ext/common/Utils/MemZeroGuard.h +5 -5
- data/ext/common/Utils/MemoryBarrier.h +1 -1
- data/ext/common/Utils/MessageIO.h +61 -61
- data/ext/common/Utils/ProcessMetricsCollector.h +40 -40
- data/ext/common/Utils/ScopeGuard.h +7 -7
- data/ext/common/Utils/SpeedMeter.h +1 -1
- data/ext/common/Utils/StrIntUtils.cpp +13 -13
- data/ext/common/Utils/StrIntUtils.h +3 -3
- data/ext/common/Utils/StringScanning.h +5 -5
- data/ext/common/Utils/SystemMetricsCollector.h +2 -2
- data/ext/common/Utils/SystemTime.h +10 -10
- data/ext/common/Utils/Template.h +2 -2
- data/ext/common/Utils/Timer.h +6 -6
- data/ext/common/Utils/VariantMap.h +29 -29
- data/ext/common/agents/Base.cpp +19 -19
- data/ext/common/agents/HelperAgent/AgentOptions.h +1 -1
- data/ext/common/agents/HelperAgent/FileBackedPipe.h +6 -6
- data/ext/common/agents/HelperAgent/Main.cpp +44 -43
- data/ext/common/agents/HelperAgent/RequestHandler.cpp +4 -4
- data/ext/common/agents/HelperAgent/RequestHandler.h +29 -28
- data/ext/common/agents/HelperAgent/ScgiRequestParser.h +56 -50
- data/ext/common/agents/LoggingAgent/AdminController.h +8 -8
- data/ext/common/agents/LoggingAgent/DataStoreId.h +17 -17
- data/ext/common/agents/LoggingAgent/FilterSupport.h +167 -167
- data/ext/common/agents/LoggingAgent/LoggingServer.h +122 -122
- data/ext/common/agents/LoggingAgent/Main.cpp +7 -7
- data/ext/common/agents/LoggingAgent/RemoteSender.h +54 -54
- data/ext/common/agents/SpawnPreparer.cpp +4 -4
- data/ext/common/agents/TempDirToucher.c +2 -2
- data/ext/common/agents/Watchdog/AgentWatcher.cpp +47 -47
- data/ext/common/agents/Watchdog/HelperAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/Main.cpp +22 -22
- data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +9 -9
- data/ext/libeio/eio.c +1 -1
- data/ext/nginx/Configuration.c +30 -30
- data/ext/nginx/Configuration.h +1 -1
- data/ext/nginx/ContentHandler.c +54 -54
- data/ext/nginx/ContentHandler.h +3 -3
- data/ext/nginx/StaticContentHandler.c +2 -2
- data/ext/nginx/ngx_http_passenger_module.c +21 -21
- data/ext/oxt/detail/backtrace_enabled.hpp +1 -1
- data/ext/oxt/detail/context.hpp +1 -1
- data/ext/oxt/detail/spin_lock_darwin.hpp +4 -4
- data/ext/oxt/detail/spin_lock_gcc_x86.hpp +3 -3
- data/ext/oxt/detail/spin_lock_pthreads.hpp +4 -4
- data/ext/oxt/detail/tracable_exception_disabled.hpp +1 -1
- data/ext/oxt/dynamic_thread_group.hpp +18 -18
- data/ext/oxt/implementation.cpp +9 -8
- data/ext/oxt/macros.hpp +2 -2
- data/ext/oxt/system_calls.cpp +11 -11
- data/ext/oxt/system_calls.hpp +13 -13
- data/ext/oxt/thread.hpp +22 -14
- data/ext/ruby/passenger_native_support.c +55 -55
- data/lib/phusion_passenger.rb +24 -24
- data/lib/phusion_passenger/common_library.rb +2 -0
- data/lib/phusion_passenger/loader_shared_helpers.rb +18 -18
- data/lib/phusion_passenger/packaging.rb +9 -4
- data/lib/phusion_passenger/platform_info/apache.rb +45 -31
- data/lib/phusion_passenger/platform_info/compiler.rb +11 -11
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
- data/lib/phusion_passenger/request_handler/thread_handler.rb +8 -8
- data/lib/phusion_passenger/standalone/app_finder.rb +16 -16
- data/lib/phusion_passenger/standalone/command.rb +22 -22
- data/packaging/rpm/LICENSE.txt +19 -0
- data/packaging/rpm/Makefile +13 -0
- data/packaging/rpm/README.md +41 -0
- data/packaging/rpm/Vagrantfile +38 -0
- data/{rpm/Vagrantfile → packaging/rpm/Vagrantfile.centos} +0 -0
- data/packaging/rpm/build +170 -0
- data/packaging/rpm/create_project +41 -0
- data/packaging/rpm/git_update +88 -0
- data/packaging/rpm/image/Dockerfile +37 -0
- data/packaging/rpm/image/Gemfile +3 -0
- data/packaging/rpm/image/Gemfile.lock +12 -0
- data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +19 -0
- data/packaging/rpm/image/amazon2014-i386.cfg +96 -0
- data/packaging/rpm/image/amazon2014-x86_64.cfg +96 -0
- data/packaging/rpm/image/site-defaults.cfg +168 -0
- data/packaging/rpm/internal/build_tasks.rb +238 -0
- data/packaging/rpm/internal/dummygpg +11 -0
- data/packaging/rpm/internal/exec_build +42 -0
- data/packaging/rpm/internal/get_distro_arch +14 -0
- data/packaging/rpm/internal/get_distro_id +10 -0
- data/packaging/rpm/internal/git_update +27 -0
- data/packaging/rpm/internal/inituidgid +17 -0
- data/packaging/rpm/internal/my_init +344 -0
- data/packaging/rpm/internal/python27 +3 -0
- data/packaging/rpm/internal/repo_update +46 -0
- data/packaging/rpm/internal/setuser +26 -0
- data/packaging/rpm/internal/tracking_helper +40 -0
- data/packaging/rpm/jenkins_release +99 -0
- data/packaging/rpm/lib/build_tasks_support.rb +402 -0
- data/packaging/rpm/lib/preprocessor.rb +341 -0
- data/packaging/rpm/nginx_spec/404.html +119 -0
- data/packaging/rpm/nginx_spec/50x.html +119 -0
- data/packaging/rpm/nginx_spec/index.html +116 -0
- data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +13 -0
- data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade +13 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade.8 +151 -0
- data/packaging/rpm/nginx_spec/nginx.conf +131 -0
- data/packaging/rpm/nginx_spec/nginx.init +144 -0
- data/packaging/rpm/nginx_spec/nginx.logrotate +13 -0
- data/packaging/rpm/nginx_spec/nginx.service +15 -0
- data/packaging/rpm/nginx_spec/nginx.spec.template +559 -0
- data/packaging/rpm/nginx_spec/nginx.sysconfig +4 -0
- data/packaging/rpm/nginx_spec/passenger.conf +9 -0
- data/packaging/rpm/nginx_spec/poweredby.png +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/apache-passenger.conf.in +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/config.json +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.logrotate +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.spec.template +58 -31
- data/{rpm → packaging/rpm/passenger_spec}/passenger_dynamic_thread_group.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger_tests_default_config_example.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-gcc47-include-sys_types.patch +0 -0
- data/packaging/rpm/repo_update +114 -0
- data/packaging/rpm/setup-system +60 -0
- data/packaging/rpm/shell +10 -0
- data/resources/templates/standalone/config.erb +3 -1
- data/test/config.json.rpm-automation +1 -1
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +11 -11
- data/test/cxx/ApplicationPool2/OptionsTest.cpp +5 -5
- data/test/cxx/ApplicationPool2/PoolTest.cpp +129 -89
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +15 -15
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +22 -22
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +11 -11
- data/test/cxx/ScgiRequestParserTest.cpp +75 -61
- data/test/cxx/UtilsTest.cpp +86 -85
- data/test/gdbinit.example +3 -0
- data/test/integration_tests/nginx_tests.rb +3 -3
- data/test/integration_tests/source_packaging_test.rb +3 -1
- data/test/stub/nginx/nginx.conf.erb +8 -1
- data/test/support/nginx_controller.rb +7 -7
- metadata +62 -17
- metadata.gz.asc +7 -7
- data/build/rpm.rb +0 -128
- data/dev/rpmtool +0 -21
- data/dev/test_rpm_packaging.sh +0 -28
- data/rpm/get_distro_id.py +0 -4
@@ -85,7 +85,7 @@ parseArguments(int argc, char *argv[]) {
|
|
85
85
|
static void
|
86
86
|
setNonBlocking(int fd) {
|
87
87
|
int flags, ret, e;
|
88
|
-
|
88
|
+
|
89
89
|
do {
|
90
90
|
flags = fcntl(fd, F_GETFL);
|
91
91
|
} while (flags == -1 && errno == EINTR);
|
@@ -146,7 +146,7 @@ initialize(int argc, char *argv[]) {
|
|
146
146
|
strerror(e), e);
|
147
147
|
exit(1);
|
148
148
|
}
|
149
|
-
|
149
|
+
|
150
150
|
setNonBlocking(terminationPipe[1]);
|
151
151
|
}
|
152
152
|
|
@@ -30,18 +30,18 @@ class AgentWatcher: public boost::enable_shared_from_this<AgentWatcher> {
|
|
30
30
|
private:
|
31
31
|
/** The watcher thread. */
|
32
32
|
oxt::thread *thr;
|
33
|
-
|
33
|
+
|
34
34
|
void threadMain(boost::shared_ptr<AgentWatcher> self) {
|
35
35
|
try {
|
36
36
|
pid_t pid, ret;
|
37
37
|
int status, e;
|
38
|
-
|
38
|
+
|
39
39
|
while (!this_thread::interruption_requested()) {
|
40
40
|
{
|
41
41
|
boost::lock_guard<boost::mutex> l(lock);
|
42
42
|
pid = this->pid;
|
43
43
|
}
|
44
|
-
|
44
|
+
|
45
45
|
// Process can be started before the watcher thread is launched.
|
46
46
|
if (pid == 0) {
|
47
47
|
pid = start();
|
@@ -63,12 +63,12 @@ private:
|
|
63
63
|
} else {
|
64
64
|
e = errno;
|
65
65
|
}
|
66
|
-
|
66
|
+
|
67
67
|
{
|
68
68
|
boost::lock_guard<boost::mutex> l(lock);
|
69
69
|
this->pid = 0;
|
70
70
|
}
|
71
|
-
|
71
|
+
|
72
72
|
this_thread::disable_interruption di;
|
73
73
|
this_thread::disable_syscall_interruption dsi;
|
74
74
|
if (ret == -1) {
|
@@ -117,21 +117,21 @@ private:
|
|
117
117
|
wo->errorEvent.notify();
|
118
118
|
}
|
119
119
|
}
|
120
|
-
|
120
|
+
|
121
121
|
protected:
|
122
122
|
/** PID of the process we're watching. 0 if no process is started at this time. */
|
123
123
|
pid_t pid;
|
124
|
-
|
124
|
+
|
125
125
|
/** If the watcher thread threw an uncaught exception then its information will
|
126
126
|
* be stored here so that the main thread can check whether a watcher encountered
|
127
127
|
* an error. These are empty strings if everything is OK.
|
128
128
|
*/
|
129
129
|
string threadExceptionMessage;
|
130
130
|
string threadExceptionBacktrace;
|
131
|
-
|
131
|
+
|
132
132
|
/** The agent process's feedback fd. */
|
133
133
|
FileDescriptor feedbackFd;
|
134
|
-
|
134
|
+
|
135
135
|
/**
|
136
136
|
* Lock for protecting the exchange of data between the main thread and
|
137
137
|
* the watcher thread.
|
@@ -139,13 +139,13 @@ protected:
|
|
139
139
|
mutable boost::mutex lock;
|
140
140
|
|
141
141
|
WorkingObjectsPtr wo;
|
142
|
-
|
142
|
+
|
143
143
|
/**
|
144
144
|
* Returns the filename of the agent process's executable. This method may be
|
145
145
|
* called in a forked child process and may therefore not allocate memory.
|
146
146
|
*/
|
147
147
|
virtual string getExeFilename() const = 0;
|
148
|
-
|
148
|
+
|
149
149
|
/**
|
150
150
|
* This method is to exec() the agent with the right arguments.
|
151
151
|
* It is called from within a forked child process, so don't do any dynamic
|
@@ -158,20 +158,20 @@ protected:
|
|
158
158
|
"3", // feedback fd
|
159
159
|
(char *) 0);
|
160
160
|
}
|
161
|
-
|
161
|
+
|
162
162
|
/**
|
163
163
|
* This method is to send startup arguments to the agent process through
|
164
164
|
* the given file descriptor, which is the agent process's feedback fd.
|
165
165
|
* May throw arbitrary exceptions.
|
166
166
|
*/
|
167
167
|
virtual void sendStartupArguments(pid_t pid, FileDescriptor &fd) = 0;
|
168
|
-
|
168
|
+
|
169
169
|
/**
|
170
170
|
* This method is to process the startup info that the agent process has
|
171
171
|
* sent back. May throw arbitrary exceptions.
|
172
172
|
*/
|
173
173
|
virtual bool processStartupInfo(pid_t pid, FileDescriptor &fd, const vector<string> &args) = 0;
|
174
|
-
|
174
|
+
|
175
175
|
static void killAndDontWait(pid_t pid) {
|
176
176
|
this_thread::disable_interruption di;
|
177
177
|
this_thread::disable_syscall_interruption dsi;
|
@@ -183,7 +183,7 @@ protected:
|
|
183
183
|
}
|
184
184
|
|
185
185
|
/**
|
186
|
-
* Kill a process with SIGKILL, and attempt to kill its children too.
|
186
|
+
* Kill a process with SIGKILL, and attempt to kill its children too.
|
187
187
|
* Then wait until it has quit.
|
188
188
|
*/
|
189
189
|
static void killAndWait(pid_t pid) {
|
@@ -196,7 +196,7 @@ protected:
|
|
196
196
|
}
|
197
197
|
syscalls::waitpid(pid, NULL, 0);
|
198
198
|
}
|
199
|
-
|
199
|
+
|
200
200
|
/**
|
201
201
|
* Behaves like <tt>waitpid(pid, status, WNOHANG)</tt>, but waits at most
|
202
202
|
* <em>timeout</em> miliseconds for the process to exit.
|
@@ -204,7 +204,7 @@ protected:
|
|
204
204
|
static int timedWaitPid(pid_t pid, int *status, unsigned long long timeout) {
|
205
205
|
Timer timer;
|
206
206
|
int ret;
|
207
|
-
|
207
|
+
|
208
208
|
do {
|
209
209
|
ret = syscalls::waitpid(pid, status, WNOHANG);
|
210
210
|
if (ret > 0 || ret == -1) {
|
@@ -215,10 +215,10 @@ protected:
|
|
215
215
|
} while (timer.elapsed() < timeout);
|
216
216
|
return 0; // timed out
|
217
217
|
}
|
218
|
-
|
218
|
+
|
219
219
|
static void waitpidUsingKillPolling(pid_t pid) {
|
220
220
|
bool done = false;
|
221
|
-
|
221
|
+
|
222
222
|
while (!done) {
|
223
223
|
int ret = syscalls::kill(pid, 0);
|
224
224
|
done = ret == -1;
|
@@ -227,18 +227,18 @@ protected:
|
|
227
227
|
}
|
228
228
|
}
|
229
229
|
}
|
230
|
-
|
230
|
+
|
231
231
|
public:
|
232
232
|
AgentWatcher(const WorkingObjectsPtr &wo) {
|
233
233
|
thr = NULL;
|
234
234
|
pid = 0;
|
235
235
|
this->wo = wo;
|
236
236
|
}
|
237
|
-
|
237
|
+
|
238
238
|
virtual ~AgentWatcher() {
|
239
239
|
delete thr;
|
240
240
|
}
|
241
|
-
|
241
|
+
|
242
242
|
/**
|
243
243
|
* Store information about the started agent process in the given report object.
|
244
244
|
* May throw arbitrary exceptions.
|
@@ -246,10 +246,10 @@ public:
|
|
246
246
|
* @pre start() has been called and succeeded.
|
247
247
|
*/
|
248
248
|
virtual void reportAgentsInformation(VariantMap &report) = 0;
|
249
|
-
|
249
|
+
|
250
250
|
/** Returns the name of the agent that this class is watching. */
|
251
251
|
virtual const char *name() const = 0;
|
252
|
-
|
252
|
+
|
253
253
|
/**
|
254
254
|
* Starts the agent process. May throw arbitrary exceptions.
|
255
255
|
*/
|
@@ -260,17 +260,17 @@ public:
|
|
260
260
|
SocketPair fds;
|
261
261
|
int e, ret;
|
262
262
|
pid_t pid;
|
263
|
-
|
263
|
+
|
264
264
|
/* Create feedback fd for this agent process. We'll send some startup
|
265
265
|
* arguments to this agent process through this fd, and we'll receive
|
266
266
|
* startup information through it as well.
|
267
267
|
*/
|
268
268
|
fds = createUnixSocketPair();
|
269
|
-
|
269
|
+
|
270
270
|
pid = syscalls::fork();
|
271
271
|
if (pid == 0) {
|
272
272
|
// Child
|
273
|
-
|
273
|
+
|
274
274
|
/* Make sure file descriptor FEEDBACK_FD refers to the newly created
|
275
275
|
* feedback fd (fds[1]) and close all other file descriptors.
|
276
276
|
* In this child process we don't care about the original FEEDBACK_FD
|
@@ -280,7 +280,7 @@ public:
|
|
280
280
|
* is started with FEEDBACK_FD already assigned.
|
281
281
|
*/
|
282
282
|
syscalls::close(fds[0]);
|
283
|
-
|
283
|
+
|
284
284
|
if (syscalls::dup2(fds[1], FEEDBACK_FD) == -1) {
|
285
285
|
/* Something went wrong, report error through feedback fd. */
|
286
286
|
e = errno;
|
@@ -298,15 +298,15 @@ public:
|
|
298
298
|
_exit(1);
|
299
299
|
}
|
300
300
|
}
|
301
|
-
|
301
|
+
|
302
302
|
closeAllFileDescriptors(FEEDBACK_FD);
|
303
|
-
|
303
|
+
|
304
304
|
/* Become the process group leader so that the watchdog can kill the
|
305
305
|
* agent as well as all its descendant processes. */
|
306
306
|
setpgid(getpid(), getpid());
|
307
|
-
|
307
|
+
|
308
308
|
setOomScore(oldOomScore);
|
309
|
-
|
309
|
+
|
310
310
|
try {
|
311
311
|
execProgram();
|
312
312
|
} catch (...) {
|
@@ -334,12 +334,12 @@ public:
|
|
334
334
|
// Parent
|
335
335
|
FileDescriptor feedbackFd = fds[0];
|
336
336
|
vector<string> args;
|
337
|
-
|
337
|
+
|
338
338
|
fds[1].close();
|
339
339
|
this_thread::restore_interruption ri(di);
|
340
340
|
this_thread::restore_syscall_interruption rsi(dsi);
|
341
341
|
ScopeGuard failGuard(boost::bind(killAndWait, pid));
|
342
|
-
|
342
|
+
|
343
343
|
/* Send startup arguments. Ignore EPIPE and ECONNRESET here
|
344
344
|
* because the child process might have sent an feedback message
|
345
345
|
* without reading startup arguments.
|
@@ -353,7 +353,7 @@ public:
|
|
353
353
|
ex.code());
|
354
354
|
}
|
355
355
|
}
|
356
|
-
|
356
|
+
|
357
357
|
// Now read its feedback.
|
358
358
|
try {
|
359
359
|
ret = readArrayMessage(feedbackFd, args);
|
@@ -370,7 +370,7 @@ public:
|
|
370
370
|
this_thread::disable_interruption di2;
|
371
371
|
this_thread::disable_syscall_interruption dsi2;
|
372
372
|
int status;
|
373
|
-
|
373
|
+
|
374
374
|
/* The feedback fd was prematurely closed for an unknown reason.
|
375
375
|
* Did the agent process crash?
|
376
376
|
*
|
@@ -405,7 +405,7 @@ public:
|
|
405
405
|
"with exit code " + toString(WEXITSTATUS(status)));
|
406
406
|
}
|
407
407
|
}
|
408
|
-
|
408
|
+
|
409
409
|
if (args[0] == "system error before exec") {
|
410
410
|
throw SystemException(string("Unable to start the ") + name() +
|
411
411
|
": " + args[1], atoi(args[2]));
|
@@ -427,7 +427,7 @@ public:
|
|
427
427
|
" sent an unknown startup info message '" +
|
428
428
|
args[0] + "'");
|
429
429
|
}
|
430
|
-
|
430
|
+
|
431
431
|
boost::lock_guard<boost::mutex> l(lock);
|
432
432
|
this->feedbackFd = feedbackFd;
|
433
433
|
this->pid = pid;
|
@@ -435,7 +435,7 @@ public:
|
|
435
435
|
return pid;
|
436
436
|
}
|
437
437
|
}
|
438
|
-
|
438
|
+
|
439
439
|
/**
|
440
440
|
* Begin watching the agent process.
|
441
441
|
*
|
@@ -453,28 +453,28 @@ public:
|
|
453
453
|
if (thr != NULL) {
|
454
454
|
throw RuntimeException("Already started watching.");
|
455
455
|
}
|
456
|
-
|
456
|
+
|
457
457
|
thr = new oxt::thread(boost::bind(&AgentWatcher::threadMain, this, shared_from_this()),
|
458
458
|
name(), 256 * 1024);
|
459
459
|
}
|
460
|
-
|
460
|
+
|
461
461
|
static void stopWatching(vector< boost::shared_ptr<AgentWatcher> > &watchers) {
|
462
462
|
vector< boost::shared_ptr<AgentWatcher> >::const_iterator it;
|
463
463
|
vector<oxt::thread *> threads;
|
464
464
|
unsigned int i = 0;
|
465
|
-
|
465
|
+
|
466
466
|
for (it = watchers.begin(); it != watchers.end(); it++, i++) {
|
467
467
|
threads.push_back((*it)->thr);
|
468
468
|
threads[i] = (*it)->thr;
|
469
469
|
}
|
470
|
-
|
470
|
+
|
471
471
|
oxt::thread::interrupt_and_join_multiple(&threads[0], threads.size());
|
472
472
|
for (it = watchers.begin(); it != watchers.end(); it++, i++) {
|
473
473
|
delete (*it)->thr;
|
474
474
|
(*it)->thr = NULL;
|
475
475
|
}
|
476
476
|
}
|
477
|
-
|
477
|
+
|
478
478
|
virtual bool signalShutdown() {
|
479
479
|
boost::lock_guard<boost::mutex> l(lock);
|
480
480
|
if (pid == 0) {
|
@@ -499,7 +499,7 @@ public:
|
|
499
499
|
return true;
|
500
500
|
}
|
501
501
|
}
|
502
|
-
|
502
|
+
|
503
503
|
/**
|
504
504
|
* If the watcher thread has encountered an error, then the error message
|
505
505
|
* will be stored here. If the error message is empty then it means
|
@@ -509,7 +509,7 @@ public:
|
|
509
509
|
boost::lock_guard<boost::mutex> l(lock);
|
510
510
|
return threadExceptionMessage;
|
511
511
|
}
|
512
|
-
|
512
|
+
|
513
513
|
/**
|
514
514
|
* The error backtrace, if applicable.
|
515
515
|
*/
|
@@ -517,7 +517,7 @@ public:
|
|
517
517
|
boost::lock_guard<boost::mutex> l(lock);
|
518
518
|
return threadExceptionBacktrace;
|
519
519
|
}
|
520
|
-
|
520
|
+
|
521
521
|
/**
|
522
522
|
* Returns the agent process feedback fd, or -1 if the agent process
|
523
523
|
* hasn't been started yet. Can be used to check whether this agent process
|
@@ -29,15 +29,15 @@ protected:
|
|
29
29
|
VariantMap params, report;
|
30
30
|
string requestSocketFilename;
|
31
31
|
string messageSocketFilename;
|
32
|
-
|
32
|
+
|
33
33
|
virtual const char *name() const {
|
34
34
|
return "Phusion Passenger helper agent";
|
35
35
|
}
|
36
|
-
|
36
|
+
|
37
37
|
virtual string getExeFilename() const {
|
38
38
|
return helperAgentFilename;
|
39
39
|
}
|
40
|
-
|
40
|
+
|
41
41
|
virtual void execProgram() const {
|
42
42
|
if (hasEnvOption("PASSENGER_RUN_HELPER_AGENT_IN_VALGRIND", false)) {
|
43
43
|
execlp("valgrind", "valgrind", "--dsymutil=yes",
|
@@ -46,13 +46,13 @@ protected:
|
|
46
46
|
execl(helperAgentFilename.c_str(), "PassengerHelperAgent", (char *) 0);
|
47
47
|
}
|
48
48
|
}
|
49
|
-
|
49
|
+
|
50
50
|
virtual void sendStartupArguments(pid_t pid, FileDescriptor &fd) {
|
51
51
|
VariantMap options = agentsOptions;
|
52
52
|
params.addTo(options);
|
53
53
|
options.writeToFd(fd);
|
54
54
|
}
|
55
|
-
|
55
|
+
|
56
56
|
virtual bool processStartupInfo(pid_t pid, FileDescriptor &fd, const vector<string> &args) {
|
57
57
|
if (args[0] == "initialized") {
|
58
58
|
requestSocketFilename = args[1];
|
@@ -62,7 +62,7 @@ protected:
|
|
62
62
|
return false;
|
63
63
|
}
|
64
64
|
}
|
65
|
-
|
65
|
+
|
66
66
|
public:
|
67
67
|
HelperAgentWatcher(const WorkingObjectsPtr &wo)
|
68
68
|
: AgentWatcher(wo)
|
@@ -88,7 +88,7 @@ public:
|
|
88
88
|
.set("logging_agent_address", wo->loggingAgentAddress)
|
89
89
|
.set("logging_agent_password", wo->loggingAgentPassword);
|
90
90
|
}
|
91
|
-
|
91
|
+
|
92
92
|
virtual void reportAgentsInformation(VariantMap &report) {
|
93
93
|
this->report.addTo(report);
|
94
94
|
}
|
@@ -27,19 +27,19 @@ class LoggingAgentWatcher: public AgentWatcher {
|
|
27
27
|
protected:
|
28
28
|
string agentFilename;
|
29
29
|
string socketAddress;
|
30
|
-
|
30
|
+
|
31
31
|
virtual const char *name() const {
|
32
32
|
return "Phusion Passenger logging agent";
|
33
33
|
}
|
34
|
-
|
34
|
+
|
35
35
|
virtual string getExeFilename() const {
|
36
36
|
return agentFilename;
|
37
37
|
}
|
38
|
-
|
38
|
+
|
39
39
|
virtual void execProgram() const {
|
40
40
|
execl(agentFilename.c_str(), "PassengerLoggingAgent", (char *) 0);
|
41
41
|
}
|
42
|
-
|
42
|
+
|
43
43
|
virtual void sendStartupArguments(pid_t pid, FileDescriptor &fd) {
|
44
44
|
VariantMap options = agentsOptions;
|
45
45
|
options.set("logging_agent_address", wo->loggingAgentAddress);
|
@@ -47,7 +47,7 @@ protected:
|
|
47
47
|
options.set("logging_agent_admin_address", wo->loggingAgentAdminAddress);
|
48
48
|
options.writeToFd(fd);
|
49
49
|
}
|
50
|
-
|
50
|
+
|
51
51
|
virtual bool processStartupInfo(pid_t pid, FileDescriptor &fd, const vector<string> &args) {
|
52
52
|
if (args[0] == "initialized") {
|
53
53
|
return true;
|
@@ -55,14 +55,14 @@ protected:
|
|
55
55
|
return false;
|
56
56
|
}
|
57
57
|
}
|
58
|
-
|
58
|
+
|
59
59
|
public:
|
60
60
|
LoggingAgentWatcher(const WorkingObjectsPtr &wo)
|
61
61
|
: AgentWatcher(wo)
|
62
62
|
{
|
63
63
|
agentFilename = wo->resourceLocator->getAgentsDir() + "/PassengerLoggingAgent";
|
64
64
|
}
|
65
|
-
|
65
|
+
|
66
66
|
virtual void reportAgentsInformation(VariantMap &report) {
|
67
67
|
report
|
68
68
|
.set("logging_socket_address", wo->loggingAgentAddress)
|