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
@@ -52,15 +52,15 @@ class ScopeGuard: public noncopyable {
|
|
52
52
|
private:
|
53
53
|
boost::function<void ()> func;
|
54
54
|
bool interruptable;
|
55
|
-
|
55
|
+
|
56
56
|
public:
|
57
57
|
ScopeGuard() { }
|
58
|
-
|
58
|
+
|
59
59
|
ScopeGuard(const boost::function<void ()> &func, bool interruptable = false) {
|
60
60
|
this->func = func;
|
61
61
|
this->interruptable = interruptable;
|
62
62
|
}
|
63
|
-
|
63
|
+
|
64
64
|
~ScopeGuard() {
|
65
65
|
if (func) {
|
66
66
|
if (interruptable) {
|
@@ -72,11 +72,11 @@ public:
|
|
72
72
|
}
|
73
73
|
}
|
74
74
|
}
|
75
|
-
|
75
|
+
|
76
76
|
void clear() {
|
77
77
|
func = boost::function<void()>();
|
78
78
|
}
|
79
|
-
|
79
|
+
|
80
80
|
void runNow() {
|
81
81
|
boost::function<void ()> oldFunc = func;
|
82
82
|
func = boost::function<void()>();
|
@@ -102,7 +102,7 @@ public:
|
|
102
102
|
StdioGuard(FILE *_f)
|
103
103
|
: f(_f)
|
104
104
|
{ }
|
105
|
-
|
105
|
+
|
106
106
|
~StdioGuard() {
|
107
107
|
if (f != NULL) {
|
108
108
|
fclose(f);
|
@@ -120,7 +120,7 @@ public:
|
|
120
120
|
: fd(_fd),
|
121
121
|
ignoreErrors(_ignoreErrors)
|
122
122
|
{ }
|
123
|
-
|
123
|
+
|
124
124
|
~FdGuard() {
|
125
125
|
if (fd != -1) {
|
126
126
|
safelyClose(fd, ignoreErrors);
|
@@ -65,7 +65,7 @@ namespace Passenger {
|
|
65
65
|
* If you have few samples then recent data have the most impact on the results.
|
66
66
|
*
|
67
67
|
* ### `minAge`
|
68
|
-
*
|
68
|
+
*
|
69
69
|
* A new sample is only accepted if at least `minAge` microseconds
|
70
70
|
* have passed since the last sample. This is to ensure that the sample
|
71
71
|
* buffer contains enough historical data so that results are not skewed by
|
@@ -40,7 +40,7 @@ fillInMiddle(unsigned int max, const string &prefix, const string &middle, const
|
|
40
40
|
if (max <= prefix.size() + postfix.size()) {
|
41
41
|
throw ArgumentException("Impossible to build string with the given size constraint.");
|
42
42
|
}
|
43
|
-
|
43
|
+
|
44
44
|
unsigned int fillSize = max - (prefix.size() + postfix.size());
|
45
45
|
if (fillSize > middle.size()) {
|
46
46
|
return prefix + middle + postfix;
|
@@ -200,7 +200,7 @@ stringToUnsignedNumeric(const StaticString &str) {
|
|
200
200
|
Numeric result = 0;
|
201
201
|
string::size_type i = 0;
|
202
202
|
const char *data = str.data();
|
203
|
-
|
203
|
+
|
204
204
|
while (data[i] == ' ' && i < str.size()) {
|
205
205
|
i++;
|
206
206
|
}
|
@@ -229,7 +229,7 @@ stringToSignedNumeric(const StaticString &str) {
|
|
229
229
|
string::size_type i = 0;
|
230
230
|
const char *data = str.data();
|
231
231
|
bool minus = false;
|
232
|
-
|
232
|
+
|
233
233
|
while (data[i] == ' ' && i < str.size()) {
|
234
234
|
i++;
|
235
235
|
}
|
@@ -266,7 +266,7 @@ hexToUnsignedNumeric(const StaticString &hex) {
|
|
266
266
|
const char *end = hex.data() + hex.size();
|
267
267
|
Numeric result = 0;
|
268
268
|
bool done = false;
|
269
|
-
|
269
|
+
|
270
270
|
while (pos < end && !done) {
|
271
271
|
char c = *pos;
|
272
272
|
if (c >= '0' && c <= '9') {
|
@@ -301,7 +301,7 @@ hexatriToULL(const StaticString &str) {
|
|
301
301
|
unsigned long long result = 0;
|
302
302
|
string::size_type i = 0;
|
303
303
|
bool done = false;
|
304
|
-
|
304
|
+
|
305
305
|
while (i < str.size() && !done) {
|
306
306
|
char c = str[i];
|
307
307
|
if (c >= '0' && c <= '9') {
|
@@ -346,7 +346,7 @@ void
|
|
346
346
|
toHex(const StaticString &data, char *output, bool upperCase) {
|
347
347
|
const char *data_buf = data.c_str();
|
348
348
|
string::size_type i;
|
349
|
-
|
349
|
+
|
350
350
|
if (upperCase) {
|
351
351
|
for (i = 0; i < data.size(); i++) {
|
352
352
|
output[i * 2] = upcase_hex_chars[(unsigned char) data_buf[i] / 16];
|
@@ -434,7 +434,7 @@ distanceOfTimeInWords(time_t fromTime, time_t toTime) {
|
|
434
434
|
} else {
|
435
435
|
seconds = fromTime - toTime;
|
436
436
|
}
|
437
|
-
|
437
|
+
|
438
438
|
if (seconds >= 60) {
|
439
439
|
time_t minutes = seconds / 60;
|
440
440
|
if (minutes >= 60) {
|
@@ -448,7 +448,7 @@ distanceOfTimeInWords(time_t fromTime, time_t toTime) {
|
|
448
448
|
minutes = minutes % 60;
|
449
449
|
result << hours << "h ";
|
450
450
|
}
|
451
|
-
|
451
|
+
|
452
452
|
seconds = seconds % 60;
|
453
453
|
result << minutes << "m ";
|
454
454
|
}
|
@@ -473,7 +473,7 @@ cEscapeString(const StaticString &input) {
|
|
473
473
|
string result;
|
474
474
|
const char *current = input.c_str();
|
475
475
|
const char *end = current + input.size();
|
476
|
-
|
476
|
+
|
477
477
|
result.reserve(input.size());
|
478
478
|
while (current < end) {
|
479
479
|
char c = *current;
|
@@ -482,7 +482,7 @@ cEscapeString(const StaticString &input) {
|
|
482
482
|
result.append(1, c);
|
483
483
|
} else {
|
484
484
|
char buf[sizeof("\\xFF")];
|
485
|
-
|
485
|
+
|
486
486
|
switch (c) {
|
487
487
|
case '\0':
|
488
488
|
// Explicitly in hex format in order to avoid confusion
|
@@ -519,10 +519,10 @@ string
|
|
519
519
|
escapeHTML(const StaticString &input) {
|
520
520
|
string result;
|
521
521
|
result.reserve((int) ceil(input.size() * 1.25));
|
522
|
-
|
522
|
+
|
523
523
|
const char *current = (const char *) input.c_str();
|
524
524
|
const char *end = current + input.size();
|
525
|
-
|
525
|
+
|
526
526
|
while (current < end) {
|
527
527
|
char ch = *current;
|
528
528
|
if (ch & 128) {
|
@@ -530,7 +530,7 @@ escapeHTML(const StaticString &input) {
|
|
530
530
|
const char *prev = current;
|
531
531
|
utf8::advance(current, 1, end);
|
532
532
|
result.append(prev, current - prev);
|
533
|
-
|
533
|
+
|
534
534
|
} else {
|
535
535
|
// ASCII character <= 127.
|
536
536
|
if (ch == '<') {
|
@@ -245,7 +245,7 @@ reverseString(char *str, unsigned int size) {
|
|
245
245
|
* Convert the given integer to some other radix, placing
|
246
246
|
* the result into the given output buffer. The output buffer
|
247
247
|
* will be NULL terminated. Supported radices are 2-36.
|
248
|
-
*
|
248
|
+
*
|
249
249
|
* @param outputSize The size of the output buffer, including space for
|
250
250
|
* the terminating NULL.
|
251
251
|
* @return The size of the created string, excluding
|
@@ -263,13 +263,13 @@ integerToOtherBase(IntegerType value, char *output, unsigned int outputSize) {
|
|
263
263
|
};
|
264
264
|
IntegerType remainder = value;
|
265
265
|
unsigned int size = 0;
|
266
|
-
|
266
|
+
|
267
267
|
do {
|
268
268
|
output[size] = chars[remainder % radix];
|
269
269
|
remainder = remainder / radix;
|
270
270
|
size++;
|
271
271
|
} while (remainder != 0 && size < outputSize - 1);
|
272
|
-
|
272
|
+
|
273
273
|
if (remainder == 0) {
|
274
274
|
reverseString(output, size);
|
275
275
|
output[size] = '\0';
|
@@ -64,7 +64,7 @@ struct ParseException {};
|
|
64
64
|
* Leading whitespaces (but not newlines) are ignored. If a word is found
|
65
65
|
* then the word is returned and the data pointer is moved to the end of
|
66
66
|
* the word.
|
67
|
-
*
|
67
|
+
*
|
68
68
|
* If the first line only contains whitespaces, or if the first line is empty,
|
69
69
|
* then a ParseException is thrown.
|
70
70
|
*
|
@@ -76,14 +76,14 @@ readNextWord(const char **data) {
|
|
76
76
|
if (**data == '\n' || **data == '\0') {
|
77
77
|
throw ParseException();
|
78
78
|
}
|
79
|
-
|
79
|
+
|
80
80
|
// Find end of word and extract the word.
|
81
81
|
const char *endOfWord = *data;
|
82
82
|
while (*endOfWord != ' ' && *endOfWord != '\n' && *endOfWord != '\0') {
|
83
83
|
endOfWord++;
|
84
84
|
}
|
85
85
|
StaticString result(*data, endOfWord - *data);
|
86
|
-
|
86
|
+
|
87
87
|
// Move data pointer to the end of this word.
|
88
88
|
*data = endOfWord;
|
89
89
|
return result;
|
@@ -200,7 +200,7 @@ readRestOfLine(const char *data) {
|
|
200
200
|
if (*data == '\n' || *data == '\0') {
|
201
201
|
return "";
|
202
202
|
}
|
203
|
-
|
203
|
+
|
204
204
|
// Look for newline character. From there, scan back until we've
|
205
205
|
// found a non-whitespace character.
|
206
206
|
const char *endOfLine = strchr(data, '\n');
|
@@ -210,7 +210,7 @@ readRestOfLine(const char *data) {
|
|
210
210
|
while (*(endOfLine - 1) == ' ') {
|
211
211
|
endOfLine--;
|
212
212
|
}
|
213
|
-
|
213
|
+
|
214
214
|
return string(data, endOfLine - data);
|
215
215
|
}
|
216
216
|
|
@@ -243,14 +243,14 @@ public:
|
|
243
243
|
*
|
244
244
|
* userUsage, niceUsage, systemUsage and idleUsage are fractions
|
245
245
|
* of user + nice + system + idle.
|
246
|
-
*
|
246
|
+
*
|
247
247
|
* ioWaitUsage is a fraction of user + nice + system + idle + iowait.
|
248
248
|
*
|
249
249
|
* stealUsage is a fraction of user + nice + system + idle + steal.
|
250
250
|
*
|
251
251
|
* All fractions range from 0 (unutilized) to SHRT_MAX (fully utilized).
|
252
252
|
* Use the *Pct() methods to convert them to percentages.
|
253
|
-
*
|
253
|
+
*
|
254
254
|
* Each statistic can individually be -1 if an error occurred while querying
|
255
255
|
* it, or -2 if the OS doesn't support it.
|
256
256
|
*/
|
@@ -75,7 +75,7 @@ public:
|
|
75
75
|
return ret;
|
76
76
|
}
|
77
77
|
}
|
78
|
-
|
78
|
+
|
79
79
|
/**
|
80
80
|
* Returns the time since the Epoch, measured in milliseconds. Or, if a
|
81
81
|
* time was forced with forceMsec(), then the forced time is returned instead.
|
@@ -90,7 +90,7 @@ public:
|
|
90
90
|
} else {
|
91
91
|
struct timeval t;
|
92
92
|
int ret;
|
93
|
-
|
93
|
+
|
94
94
|
do {
|
95
95
|
ret = gettimeofday(&t, NULL);
|
96
96
|
} while (ret == -1 && errno == EINTR);
|
@@ -103,7 +103,7 @@ public:
|
|
103
103
|
return (unsigned long long) t.tv_sec * 1000 + t.tv_usec / 1000;
|
104
104
|
}
|
105
105
|
}
|
106
|
-
|
106
|
+
|
107
107
|
/**
|
108
108
|
* Returns the time since the Epoch, measured in microseconds. Or, if a
|
109
109
|
* time was forced with forceUsec(), then the forced time is returned instead.
|
@@ -117,7 +117,7 @@ public:
|
|
117
117
|
} else {
|
118
118
|
struct timeval t;
|
119
119
|
int ret;
|
120
|
-
|
120
|
+
|
121
121
|
do {
|
122
122
|
ret = gettimeofday(&t, NULL);
|
123
123
|
} while (ret == -1 && errno == EINTR);
|
@@ -138,7 +138,7 @@ public:
|
|
138
138
|
SystemTimeData::hasForcedValue = true;
|
139
139
|
SystemTimeData::forcedValue = value;
|
140
140
|
}
|
141
|
-
|
141
|
+
|
142
142
|
/**
|
143
143
|
* Force getMsec() to return the given value.
|
144
144
|
*/
|
@@ -146,7 +146,7 @@ public:
|
|
146
146
|
SystemTimeData::hasForcedMsecValue = true;
|
147
147
|
SystemTimeData::forcedMsecValue = value;
|
148
148
|
}
|
149
|
-
|
149
|
+
|
150
150
|
/**
|
151
151
|
* Force getUsec() to return the given value.
|
152
152
|
*/
|
@@ -154,7 +154,7 @@ public:
|
|
154
154
|
SystemTimeData::hasForcedUsecValue = true;
|
155
155
|
SystemTimeData::forcedUsecValue = value;
|
156
156
|
}
|
157
|
-
|
157
|
+
|
158
158
|
static void forceAll(unsigned long long usec) {
|
159
159
|
force(usec / 1000000);
|
160
160
|
forceMsec(usec / 1000);
|
@@ -168,7 +168,7 @@ public:
|
|
168
168
|
static void release() {
|
169
169
|
SystemTimeData::hasForcedValue = false;
|
170
170
|
}
|
171
|
-
|
171
|
+
|
172
172
|
/**
|
173
173
|
* Release the previously forced msec value, so that getMsec()
|
174
174
|
* returns the system time once again.
|
@@ -176,7 +176,7 @@ public:
|
|
176
176
|
static void releaseMsec() {
|
177
177
|
SystemTimeData::hasForcedMsecValue = false;
|
178
178
|
}
|
179
|
-
|
179
|
+
|
180
180
|
/**
|
181
181
|
* Release the previously forced usec value, so that getUsec()
|
182
182
|
* returns the system time once again.
|
@@ -184,7 +184,7 @@ public:
|
|
184
184
|
static void releaseUsec() {
|
185
185
|
SystemTimeData::hasForcedUsecValue = false;
|
186
186
|
}
|
187
|
-
|
187
|
+
|
188
188
|
/**
|
189
189
|
* Release all previously forced values, so that get(), getMsec()
|
190
190
|
* and getUsec() return the system time once again.
|
data/ext/common/Utils/Template.h
CHANGED
@@ -168,7 +168,7 @@ private:
|
|
168
168
|
if (endPos == string::npos) {
|
169
169
|
return state.result.size();
|
170
170
|
}
|
171
|
-
|
171
|
+
|
172
172
|
string name = state.result.substr(pos + 2, endPos - pos - 2);
|
173
173
|
if (startsWith(name, "if ")) {
|
174
174
|
return processIf(state, pos, endPos, name);
|
@@ -194,7 +194,7 @@ public:
|
|
194
194
|
Template(const StaticString &_content)
|
195
195
|
: content(_content)
|
196
196
|
{ }
|
197
|
-
|
197
|
+
|
198
198
|
string apply(const StringMap<StaticString> &substitutions) {
|
199
199
|
State state(content, substitutions);
|
200
200
|
apply(state);
|
data/ext/common/Utils/Timer.h
CHANGED
@@ -65,7 +65,7 @@ public:
|
|
65
65
|
stop();
|
66
66
|
}
|
67
67
|
}
|
68
|
-
|
68
|
+
|
69
69
|
/**
|
70
70
|
* Start the timer. If the timer was already started, then this will
|
71
71
|
* restart the timer.
|
@@ -80,7 +80,7 @@ public:
|
|
80
80
|
ret = gettimeofday(&startTime, NULL);
|
81
81
|
} while (ret == -1 && errno == EINTR);
|
82
82
|
}
|
83
|
-
|
83
|
+
|
84
84
|
/**
|
85
85
|
* Stop the timer. If there's currently another thread waiting on the wait()
|
86
86
|
* call, then that wait() call will block indefinitely until you call start()
|
@@ -118,7 +118,7 @@ public:
|
|
118
118
|
struct timeval t;
|
119
119
|
unsigned long long now, beginning;
|
120
120
|
int ret;
|
121
|
-
|
121
|
+
|
122
122
|
do {
|
123
123
|
ret = gettimeofday(&t, NULL);
|
124
124
|
} while (ret == -1 && errno == EINTR);
|
@@ -127,7 +127,7 @@ public:
|
|
127
127
|
return now - beginning;
|
128
128
|
}
|
129
129
|
}
|
130
|
-
|
130
|
+
|
131
131
|
/**
|
132
132
|
* Returns the amount of time that has elapsed since the timer was last started,
|
133
133
|
* in microseconds. If the timer is currently stopped, then 0 is returned.
|
@@ -140,7 +140,7 @@ public:
|
|
140
140
|
struct timeval t;
|
141
141
|
unsigned long long now, beginning;
|
142
142
|
int ret;
|
143
|
-
|
143
|
+
|
144
144
|
do {
|
145
145
|
ret = gettimeofday(&t, NULL);
|
146
146
|
} while (ret == -1 && errno == EINTR);
|
@@ -149,7 +149,7 @@ public:
|
|
149
149
|
return now - beginning;
|
150
150
|
}
|
151
151
|
}
|
152
|
-
|
152
|
+
|
153
153
|
/**
|
154
154
|
* Wait until <em>time</em> miliseconds have elapsed since the timer
|
155
155
|
* was last started.
|
@@ -60,7 +60,7 @@ class VariantMap {
|
|
60
60
|
private:
|
61
61
|
map<string, string> store;
|
62
62
|
string empty;
|
63
|
-
|
63
|
+
|
64
64
|
/**
|
65
65
|
* Looks up the string value associated with <em>name</em>.
|
66
66
|
* If found, then <tt>true</tt> is returned and a pointer to
|
@@ -85,26 +85,26 @@ private:
|
|
85
85
|
return true;
|
86
86
|
}
|
87
87
|
}
|
88
|
-
|
88
|
+
|
89
89
|
public:
|
90
90
|
/** Thrown when a required key is not found by one of the get() methods. */
|
91
91
|
class MissingKeyException: public oxt::tracable_exception {
|
92
92
|
private:
|
93
93
|
string message;
|
94
94
|
string key;
|
95
|
-
|
95
|
+
|
96
96
|
public:
|
97
97
|
MissingKeyException(const string &key) {
|
98
98
|
this->key = key;
|
99
99
|
message = string("Required key '") + key + "' is missing";
|
100
100
|
}
|
101
|
-
|
101
|
+
|
102
102
|
virtual ~MissingKeyException() throw() { }
|
103
|
-
|
103
|
+
|
104
104
|
virtual const char *what() const throw() {
|
105
105
|
return message.c_str();
|
106
106
|
}
|
107
|
-
|
107
|
+
|
108
108
|
/** The key that wasn't found. */
|
109
109
|
const string &getKey() const {
|
110
110
|
return key;
|
@@ -140,7 +140,7 @@ public:
|
|
140
140
|
i += 2;
|
141
141
|
}
|
142
142
|
}
|
143
|
-
|
143
|
+
|
144
144
|
/**
|
145
145
|
* Populates a VariantMap from the data in `fd`. MessageIO
|
146
146
|
* is used to read from the file descriptor.
|
@@ -151,7 +151,7 @@ public:
|
|
151
151
|
void readFrom(int fd, const StaticString &messageName = "VariantMap") {
|
152
152
|
TRACE_POINT();
|
153
153
|
vector<string> args;
|
154
|
-
|
154
|
+
|
155
155
|
if (!readArrayMessage(fd, args)) {
|
156
156
|
throw IOException("Unexpected end-of-file encountered");
|
157
157
|
}
|
@@ -164,7 +164,7 @@ public:
|
|
164
164
|
if (args.size() % 2 != 1) {
|
165
165
|
throw IOException("Message from channel has an unexpected number of arguments");
|
166
166
|
}
|
167
|
-
|
167
|
+
|
168
168
|
vector<string>::const_iterator it = args.begin();
|
169
169
|
it++;
|
170
170
|
while (it != args.end()) {
|
@@ -175,7 +175,7 @@ public:
|
|
175
175
|
store[key] = value;
|
176
176
|
}
|
177
177
|
}
|
178
|
-
|
178
|
+
|
179
179
|
VariantMap &set(const string &name, const string &value) {
|
180
180
|
if (value.empty()) {
|
181
181
|
map<string, string>::iterator it = store.find(name);
|
@@ -194,7 +194,7 @@ public:
|
|
194
194
|
}
|
195
195
|
return *this;
|
196
196
|
}
|
197
|
-
|
197
|
+
|
198
198
|
VariantMap &setInt(const string &name, int value) {
|
199
199
|
set(name, toString(value));
|
200
200
|
return *this;
|
@@ -206,7 +206,7 @@ public:
|
|
206
206
|
}
|
207
207
|
return *this;
|
208
208
|
}
|
209
|
-
|
209
|
+
|
210
210
|
VariantMap &setULL(const string &name, unsigned long long value) {
|
211
211
|
set(name, toString(value));
|
212
212
|
return *this;
|
@@ -218,7 +218,7 @@ public:
|
|
218
218
|
}
|
219
219
|
return *this;
|
220
220
|
}
|
221
|
-
|
221
|
+
|
222
222
|
VariantMap &setPid(const string &name, pid_t value) {
|
223
223
|
set(name, toString((unsigned long long) value));
|
224
224
|
return *this;
|
@@ -230,7 +230,7 @@ public:
|
|
230
230
|
}
|
231
231
|
return *this;
|
232
232
|
}
|
233
|
-
|
233
|
+
|
234
234
|
VariantMap &setUid(const string &name, uid_t value) {
|
235
235
|
set(name, toString((long long) value));
|
236
236
|
return *this;
|
@@ -242,7 +242,7 @@ public:
|
|
242
242
|
}
|
243
243
|
return *this;
|
244
244
|
}
|
245
|
-
|
245
|
+
|
246
246
|
VariantMap &setGid(const string &name, gid_t value) {
|
247
247
|
set(name, toString((long long) value));
|
248
248
|
return *this;
|
@@ -254,7 +254,7 @@ public:
|
|
254
254
|
}
|
255
255
|
return *this;
|
256
256
|
}
|
257
|
-
|
257
|
+
|
258
258
|
VariantMap &setBool(const string &name, bool value) {
|
259
259
|
set(name, value ? "true" : "false");
|
260
260
|
return *this;
|
@@ -291,7 +291,7 @@ public:
|
|
291
291
|
return it->second;
|
292
292
|
}
|
293
293
|
}
|
294
|
-
|
294
|
+
|
295
295
|
const string &get(const string &name, bool required, const string &defaultValue) const {
|
296
296
|
map<string, string>::const_iterator it = store.find(name);
|
297
297
|
if (it == store.end()) {
|
@@ -304,7 +304,7 @@ public:
|
|
304
304
|
return it->second;
|
305
305
|
}
|
306
306
|
}
|
307
|
-
|
307
|
+
|
308
308
|
int getInt(const string &name, bool required = true, int defaultValue = 0) const {
|
309
309
|
int result = defaultValue;
|
310
310
|
const string *str;
|
@@ -313,7 +313,7 @@ public:
|
|
313
313
|
}
|
314
314
|
return result;
|
315
315
|
}
|
316
|
-
|
316
|
+
|
317
317
|
unsigned long long getULL(const string &name, bool required = true,
|
318
318
|
unsigned long long defaultValue = 0) const
|
319
319
|
{
|
@@ -324,7 +324,7 @@ public:
|
|
324
324
|
}
|
325
325
|
return result;
|
326
326
|
}
|
327
|
-
|
327
|
+
|
328
328
|
pid_t getPid(const string &name, bool required = true, pid_t defaultValue = 0) const {
|
329
329
|
pid_t result = defaultValue;
|
330
330
|
const string *str;
|
@@ -333,7 +333,7 @@ public:
|
|
333
333
|
}
|
334
334
|
return result;
|
335
335
|
}
|
336
|
-
|
336
|
+
|
337
337
|
uid_t getUid(const string &name, bool required = true, uid_t defaultValue = 0) const {
|
338
338
|
uid_t result = defaultValue;
|
339
339
|
const string *str;
|
@@ -342,7 +342,7 @@ public:
|
|
342
342
|
}
|
343
343
|
return result;
|
344
344
|
}
|
345
|
-
|
345
|
+
|
346
346
|
gid_t getGid(const string &name, bool required = true, gid_t defaultValue = 0) const {
|
347
347
|
gid_t result = defaultValue;
|
348
348
|
const string *str;
|
@@ -351,7 +351,7 @@ public:
|
|
351
351
|
}
|
352
352
|
return result;
|
353
353
|
}
|
354
|
-
|
354
|
+
|
355
355
|
bool getBool(const string &name, bool required = true, bool defaultValue = false) const {
|
356
356
|
bool result = defaultValue;
|
357
357
|
const string *str;
|
@@ -372,16 +372,16 @@ public:
|
|
372
372
|
}
|
373
373
|
return result;
|
374
374
|
}
|
375
|
-
|
375
|
+
|
376
376
|
bool erase(const string &name) {
|
377
377
|
return store.erase(name) != 0;
|
378
378
|
}
|
379
|
-
|
379
|
+
|
380
380
|
/** Checks whether the specified key is in this map. */
|
381
381
|
bool has(const string &name) const {
|
382
382
|
return store.find(name) != store.end();
|
383
383
|
}
|
384
|
-
|
384
|
+
|
385
385
|
/** Returns the number of elements in this map. */
|
386
386
|
unsigned int size() const {
|
387
387
|
return store.size();
|
@@ -395,7 +395,7 @@ public:
|
|
395
395
|
other.set(it->first, it->second);
|
396
396
|
}
|
397
397
|
}
|
398
|
-
|
398
|
+
|
399
399
|
/**
|
400
400
|
* Writes a representation of the contents in this VariantMap to
|
401
401
|
* the given file descriptor with MessageIO. The data can be
|
@@ -407,7 +407,7 @@ public:
|
|
407
407
|
map<string, string>::const_iterator it;
|
408
408
|
map<string, string>::const_iterator end = store.end();
|
409
409
|
vector<string> args;
|
410
|
-
|
410
|
+
|
411
411
|
args.reserve(1 + 2 * store.size());
|
412
412
|
args.push_back(messageName);
|
413
413
|
for (it = store.begin(); it != end; it++) {
|
@@ -438,7 +438,7 @@ public:
|
|
438
438
|
map<string, string>::const_iterator end = store.end();
|
439
439
|
string result;
|
440
440
|
unsigned int i = 0;
|
441
|
-
|
441
|
+
|
442
442
|
result.append("{ ");
|
443
443
|
for (it = store.begin(); it != end; it++, i++) {
|
444
444
|
result.append("'");
|