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
@@ -53,7 +53,7 @@ private:
|
|
53
53
|
string docDir;
|
54
54
|
string rubyLibDir;
|
55
55
|
string nodeLibDir;
|
56
|
-
|
56
|
+
|
57
57
|
static string getOption(const string &file, const IniFileSectionPtr §ion, const string &key) {
|
58
58
|
if (section->hasKey(key)) {
|
59
59
|
return section->get(key);
|
@@ -61,7 +61,7 @@ private:
|
|
61
61
|
throw RuntimeException("Option '" + key + "' missing in file '" + file + "'");
|
62
62
|
}
|
63
63
|
}
|
64
|
-
|
64
|
+
|
65
65
|
public:
|
66
66
|
ResourceLocator(const string &rootOrFile) {
|
67
67
|
root = rootOrFile;
|
@@ -86,27 +86,27 @@ public:
|
|
86
86
|
nodeLibDir = root + "/node_lib";
|
87
87
|
}
|
88
88
|
}
|
89
|
-
|
89
|
+
|
90
90
|
string getRoot() const {
|
91
91
|
return root;
|
92
92
|
}
|
93
|
-
|
93
|
+
|
94
94
|
string getAgentsDir() const {
|
95
95
|
return agentsDir;
|
96
96
|
}
|
97
|
-
|
97
|
+
|
98
98
|
string getHelperScriptsDir() const {
|
99
99
|
return helperScriptsDir;
|
100
100
|
}
|
101
|
-
|
101
|
+
|
102
102
|
string getResourcesDir() const {
|
103
103
|
return resourcesDir;
|
104
104
|
}
|
105
|
-
|
105
|
+
|
106
106
|
string getDocDir() const {
|
107
107
|
return docDir;
|
108
108
|
}
|
109
|
-
|
109
|
+
|
110
110
|
// Can be empty.
|
111
111
|
string getRubyLibDir() const {
|
112
112
|
return rubyLibDir;
|
data/ext/common/SafeLibev.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010
|
3
|
+
* Copyright (c) 2010-2014 Phusion
|
4
4
|
*
|
5
5
|
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
6
|
*
|
@@ -29,11 +29,11 @@
|
|
29
29
|
#include <vector>
|
30
30
|
#include <list>
|
31
31
|
#include <memory>
|
32
|
-
#include <climits>
|
33
32
|
#include <boost/thread.hpp>
|
34
33
|
#include <boost/shared_ptr.hpp>
|
35
34
|
#include <boost/function.hpp>
|
36
35
|
#include <boost/bind.hpp>
|
36
|
+
#include <oxt/thread.hpp>
|
37
37
|
|
38
38
|
namespace Passenger {
|
39
39
|
|
@@ -46,27 +46,33 @@ using namespace boost;
|
|
46
46
|
*/
|
47
47
|
class SafeLibev {
|
48
48
|
private:
|
49
|
+
// 2^28-1. Command IDs are 28-bit so that we can pack DataSource's state and
|
50
|
+
// its planId in 32-bits total.
|
51
|
+
static const unsigned int MAX_COMMAND_ID = 268435455;
|
52
|
+
|
49
53
|
typedef boost::function<void ()> Callback;
|
50
54
|
|
51
55
|
struct Command {
|
52
|
-
int id;
|
53
56
|
Callback callback;
|
57
|
+
unsigned int id: 31;
|
58
|
+
bool canceled: 1;
|
54
59
|
|
55
60
|
Command(unsigned int _id, const Callback &_callback)
|
56
|
-
:
|
57
|
-
|
61
|
+
: callback(_callback),
|
62
|
+
id(_id),
|
63
|
+
canceled(false)
|
58
64
|
{ }
|
59
65
|
};
|
60
66
|
|
61
67
|
struct ev_loop *loop;
|
62
68
|
pthread_t loopThread;
|
63
69
|
ev_async async;
|
64
|
-
|
70
|
+
|
65
71
|
boost::mutex syncher;
|
66
72
|
boost::condition_variable cond;
|
67
73
|
vector<Command> commands;
|
68
74
|
unsigned int nextCommandId;
|
69
|
-
|
75
|
+
|
70
76
|
static void asyncHandler(EV_P_ ev_async *w, int revents) {
|
71
77
|
SafeLibev *self = (SafeLibev *) w->data;
|
72
78
|
self->runCommands();
|
@@ -82,13 +88,15 @@ private:
|
|
82
88
|
vector<Command> commands = this->commands;
|
83
89
|
this->commands.clear();
|
84
90
|
l.unlock();
|
85
|
-
|
91
|
+
|
86
92
|
vector<Command>::const_iterator it, end = commands.end();
|
87
93
|
for (it = commands.begin(); it != end; it++) {
|
88
|
-
it->
|
94
|
+
if (!it->canceled) {
|
95
|
+
it->callback();
|
96
|
+
}
|
89
97
|
}
|
90
98
|
}
|
91
|
-
|
99
|
+
|
92
100
|
template<typename Watcher>
|
93
101
|
void startWatcherAndNotify(Watcher *watcher, bool *done) {
|
94
102
|
watcher->set(loop);
|
@@ -97,7 +105,7 @@ private:
|
|
97
105
|
*done = true;
|
98
106
|
cond.notify_all();
|
99
107
|
}
|
100
|
-
|
108
|
+
|
101
109
|
template<typename Watcher>
|
102
110
|
void stopWatcherAndNotify(Watcher *watcher, bool *done) {
|
103
111
|
watcher->stop();
|
@@ -105,7 +113,7 @@ private:
|
|
105
113
|
*done = true;
|
106
114
|
cond.notify_all();
|
107
115
|
}
|
108
|
-
|
116
|
+
|
109
117
|
void runAndNotify(const Callback *callback, bool *done) {
|
110
118
|
(*callback)();
|
111
119
|
boost::unique_lock<boost::mutex> l(syncher);
|
@@ -114,26 +122,26 @@ private:
|
|
114
122
|
}
|
115
123
|
|
116
124
|
void incNextCommandId() {
|
117
|
-
if (nextCommandId ==
|
118
|
-
nextCommandId =
|
125
|
+
if (nextCommandId == MAX_COMMAND_ID) {
|
126
|
+
nextCommandId = 1;
|
119
127
|
} else {
|
120
128
|
nextCommandId++;
|
121
129
|
}
|
122
130
|
}
|
123
|
-
|
131
|
+
|
124
132
|
public:
|
125
133
|
/** SafeLibev takes over ownership of the loop object. */
|
126
134
|
SafeLibev(struct ev_loop *loop) {
|
127
135
|
this->loop = loop;
|
128
136
|
loopThread = pthread_self();
|
129
|
-
nextCommandId =
|
130
|
-
|
137
|
+
nextCommandId = 1;
|
138
|
+
|
131
139
|
ev_async_init(&async, asyncHandler);
|
132
140
|
ev_set_priority(&async, EV_MAXPRI);
|
133
141
|
async.data = this;
|
134
142
|
ev_async_start(loop, &async);
|
135
143
|
}
|
136
|
-
|
144
|
+
|
137
145
|
~SafeLibev() {
|
138
146
|
destroy();
|
139
147
|
ev_loop_destroy(loop);
|
@@ -142,19 +150,36 @@ public:
|
|
142
150
|
void destroy() {
|
143
151
|
ev_async_stop(loop, &async);
|
144
152
|
}
|
145
|
-
|
153
|
+
|
146
154
|
struct ev_loop *getLoop() const {
|
147
155
|
return loop;
|
148
156
|
}
|
149
|
-
|
157
|
+
|
150
158
|
void setCurrentThread() {
|
151
159
|
loopThread = pthread_self();
|
160
|
+
#ifdef OXT_THREAD_LOCAL_KEYWORD_SUPPORTED
|
161
|
+
oxt::thread_signature = this;
|
162
|
+
#endif
|
152
163
|
}
|
153
164
|
|
154
165
|
pthread_t getCurrentThread() const {
|
155
166
|
return loopThread;
|
156
167
|
}
|
157
|
-
|
168
|
+
|
169
|
+
bool onEventLoopThread() const {
|
170
|
+
#ifdef OXT_THREAD_LOCAL_KEYWORD_SUPPORTED
|
171
|
+
// Avoid double reads of the thread-local variable.
|
172
|
+
const void *sig = oxt::thread_signature;
|
173
|
+
if (OXT_UNLIKELY(sig == NULL)) {
|
174
|
+
return pthread_equal(pthread_self(), loopThread);
|
175
|
+
} else {
|
176
|
+
return sig == this;
|
177
|
+
}
|
178
|
+
#else
|
179
|
+
return pthread_equal(pthread_self(), loopThread);
|
180
|
+
#endif
|
181
|
+
}
|
182
|
+
|
158
183
|
template<typename Watcher>
|
159
184
|
void start(Watcher &watcher) {
|
160
185
|
if (pthread_equal(pthread_self(), loopThread)) {
|
@@ -173,7 +198,7 @@ public:
|
|
173
198
|
}
|
174
199
|
}
|
175
200
|
}
|
176
|
-
|
201
|
+
|
177
202
|
template<typename Watcher>
|
178
203
|
void stop(Watcher &watcher) {
|
179
204
|
if (pthread_equal(pthread_self(), loopThread)) {
|
@@ -191,7 +216,7 @@ public:
|
|
191
216
|
}
|
192
217
|
}
|
193
218
|
}
|
194
|
-
|
219
|
+
|
195
220
|
void run(const Callback &callback) {
|
196
221
|
assert(callback != NULL);
|
197
222
|
if (pthread_equal(pthread_self(), loopThread)) {
|
@@ -251,14 +276,18 @@ public:
|
|
251
276
|
* in the future, while a return value of false means that the callback has already
|
252
277
|
* been called or is currently being called.
|
253
278
|
*/
|
254
|
-
bool cancelCommand(int id) {
|
279
|
+
bool cancelCommand(unsigned int id) {
|
280
|
+
if (id == 0) {
|
281
|
+
return false;
|
282
|
+
}
|
283
|
+
|
255
284
|
boost::unique_lock<boost::mutex> l(syncher);
|
256
285
|
// TODO: we can do a binary search because the command ID
|
257
286
|
// is monotically increasing except on overflow.
|
258
287
|
vector<Command>::iterator it, end = commands.end();
|
259
288
|
for (it = commands.begin(); it != end; it++) {
|
260
289
|
if (it->id == id) {
|
261
|
-
|
290
|
+
it->canceled = true;
|
262
291
|
return true;
|
263
292
|
}
|
264
293
|
}
|
@@ -64,17 +64,17 @@ public:
|
|
64
64
|
class Generation: public noncopyable {
|
65
65
|
private:
|
66
66
|
friend class ServerInstanceDir;
|
67
|
-
|
67
|
+
|
68
68
|
string path;
|
69
69
|
unsigned int number;
|
70
70
|
bool owner;
|
71
|
-
|
71
|
+
|
72
72
|
Generation(const string &serverInstanceDir, unsigned int number) {
|
73
73
|
path = serverInstanceDir + "/generation-" + toString(number);
|
74
74
|
this->number = number;
|
75
75
|
owner = false;
|
76
76
|
}
|
77
|
-
|
77
|
+
|
78
78
|
void create(bool userSwitching, const string &defaultUser,
|
79
79
|
const string &defaultGroup, uid_t webServerWorkerUid,
|
80
80
|
gid_t webServerWorkerGid)
|
@@ -84,7 +84,7 @@ public:
|
|
84
84
|
struct passwd *defaultUserEntry;
|
85
85
|
uid_t defaultUid;
|
86
86
|
gid_t defaultGid;
|
87
|
-
|
87
|
+
|
88
88
|
defaultUserEntry = getpwnam(defaultUser.c_str());
|
89
89
|
if (defaultUserEntry == NULL) {
|
90
90
|
throw NonExistentUserException("Default user '" + defaultUser +
|
@@ -96,26 +96,26 @@ public:
|
|
96
96
|
throw NonExistentGroupException("Default group '" + defaultGroup +
|
97
97
|
"' does not exist.");
|
98
98
|
}
|
99
|
-
|
99
|
+
|
100
100
|
/* We set a very tight permission here: no read or write access for
|
101
101
|
* anybody except the owner. The individual files and subdirectories
|
102
102
|
* decide for themselves whether they're readable by anybody.
|
103
103
|
*/
|
104
104
|
makeDirTree(path, "u=rwx,g=x,o=x");
|
105
|
-
|
105
|
+
|
106
106
|
/* Write structure version file. */
|
107
107
|
string structureVersionFile = path + "/structure_version.txt";
|
108
108
|
createFile(structureVersionFile,
|
109
109
|
toString(SERVER_INSTANCE_DIR_GENERATION_STRUCTURE_MAJOR_VERSION) + "." +
|
110
110
|
toString(SERVER_INSTANCE_DIR_GENERATION_STRUCTURE_MINOR_VERSION),
|
111
111
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
112
|
-
|
112
|
+
|
113
113
|
string passengerVersionFile = path + "/passenger_version.txt";
|
114
114
|
createFile(passengerVersionFile,
|
115
115
|
PASSENGER_VERSION "\n",
|
116
116
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
117
|
-
|
118
|
-
|
117
|
+
|
118
|
+
|
119
119
|
/* We want the upload buffer directory to be only writable by the web
|
120
120
|
* server's worker processs. Other users may not have any access to this
|
121
121
|
* directory.
|
@@ -126,7 +126,7 @@ public:
|
|
126
126
|
} else {
|
127
127
|
makeDirTree(path + "/buffered_uploads", "u=rwx,g=,o=");
|
128
128
|
}
|
129
|
-
|
129
|
+
|
130
130
|
/* The HelperAgent must be able to connect to an application. */
|
131
131
|
if (runningAsRoot) {
|
132
132
|
if (userSwitching) {
|
@@ -153,10 +153,10 @@ public:
|
|
153
153
|
*/
|
154
154
|
makeDirTree(path + "/backends", "u=rwx,g=,o=");
|
155
155
|
}
|
156
|
-
|
156
|
+
|
157
157
|
owner = true;
|
158
158
|
}
|
159
|
-
|
159
|
+
|
160
160
|
public:
|
161
161
|
~Generation() {
|
162
162
|
destroy();
|
@@ -167,30 +167,30 @@ public:
|
|
167
167
|
removeDirTree(path);
|
168
168
|
}
|
169
169
|
}
|
170
|
-
|
170
|
+
|
171
171
|
unsigned int getNumber() const {
|
172
172
|
return number;
|
173
173
|
}
|
174
|
-
|
174
|
+
|
175
175
|
// The 'const strng &' here is on purpose. The AgentsStarter C
|
176
176
|
// functions return the string pointer directly.
|
177
177
|
const string &getPath() const {
|
178
178
|
return path;
|
179
179
|
}
|
180
|
-
|
180
|
+
|
181
181
|
void detach() {
|
182
182
|
owner = false;
|
183
183
|
}
|
184
184
|
};
|
185
|
-
|
185
|
+
|
186
186
|
typedef boost::shared_ptr<Generation> GenerationPtr;
|
187
|
-
|
187
|
+
|
188
188
|
private:
|
189
189
|
string path;
|
190
190
|
bool owner;
|
191
|
-
|
191
|
+
|
192
192
|
friend class Generation;
|
193
|
-
|
193
|
+
|
194
194
|
void initialize(const string &path, bool owner) {
|
195
195
|
TRACE_POINT();
|
196
196
|
struct stat buf;
|
@@ -198,7 +198,7 @@ private:
|
|
198
198
|
|
199
199
|
this->path = path;
|
200
200
|
this->owner = owner;
|
201
|
-
|
201
|
+
|
202
202
|
/* Create the server instance directory. We only need to write to this
|
203
203
|
* directory for these reasons:
|
204
204
|
* 1. Initial population of structure files (structure_version.txt, instance.pid).
|
@@ -288,7 +288,7 @@ private:
|
|
288
288
|
path + ", but it has wrong owner and group");
|
289
289
|
}
|
290
290
|
}
|
291
|
-
|
291
|
+
|
292
292
|
bool isDirectory(const string &dir, struct dirent *entry) const {
|
293
293
|
#ifdef DT_DIR
|
294
294
|
if (entry->d_type == DT_DIR) {
|
@@ -303,12 +303,12 @@ private:
|
|
303
303
|
path.append(entry->d_name);
|
304
304
|
return getFileType(path) == FT_DIRECTORY;
|
305
305
|
}
|
306
|
-
|
306
|
+
|
307
307
|
public:
|
308
308
|
ServerInstanceDir(const string &path, bool owner = true) {
|
309
309
|
initialize(path, owner);
|
310
310
|
}
|
311
|
-
|
311
|
+
|
312
312
|
~ServerInstanceDir() {
|
313
313
|
destroy();
|
314
314
|
}
|
@@ -330,17 +330,17 @@ public:
|
|
330
330
|
}
|
331
331
|
}
|
332
332
|
}
|
333
|
-
|
333
|
+
|
334
334
|
// The 'const strng &' here is on purpose. The AgentsStarter C
|
335
335
|
// functions return the string pointer directly.
|
336
336
|
const string &getPath() const {
|
337
337
|
return path;
|
338
338
|
}
|
339
|
-
|
339
|
+
|
340
340
|
void detach() {
|
341
341
|
owner = false;
|
342
342
|
}
|
343
|
-
|
343
|
+
|
344
344
|
GenerationPtr newGeneration(bool userSwitching, const string &defaultUser,
|
345
345
|
const string &defaultGroup, uid_t webServerWorkerUid,
|
346
346
|
gid_t webServerWorkerGid)
|
@@ -352,24 +352,24 @@ public:
|
|
352
352
|
} else {
|
353
353
|
newNumber = 0;
|
354
354
|
}
|
355
|
-
|
355
|
+
|
356
356
|
GenerationPtr generation(new Generation(path, newNumber));
|
357
357
|
generation->create(userSwitching, defaultUser, defaultGroup,
|
358
358
|
webServerWorkerUid, webServerWorkerGid);
|
359
359
|
return generation;
|
360
360
|
}
|
361
|
-
|
361
|
+
|
362
362
|
GenerationPtr getGeneration(unsigned int number) const {
|
363
363
|
// Must not used boost::make_shared() here because Watchdog.cpp
|
364
364
|
// deletes the raw pointer in cleanupAgentsInBackground().
|
365
365
|
return ptr(new Generation(path, number));
|
366
366
|
}
|
367
|
-
|
367
|
+
|
368
368
|
GenerationPtr getNewestGeneration() const {
|
369
369
|
DIR *dir = opendir(path.c_str());
|
370
370
|
struct dirent *entry;
|
371
371
|
int result = -1;
|
372
|
-
|
372
|
+
|
373
373
|
if (dir == NULL) {
|
374
374
|
int e = errno;
|
375
375
|
throw FileSystemException("Cannot open directory " + path,
|
@@ -386,7 +386,7 @@ public:
|
|
386
386
|
}
|
387
387
|
}
|
388
388
|
closedir(dir);
|
389
|
-
|
389
|
+
|
390
390
|
if (result == -1) {
|
391
391
|
return GenerationPtr();
|
392
392
|
} else {
|