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
data/ext/common/FileDescriptor.h
CHANGED
@@ -68,19 +68,19 @@ private:
|
|
68
68
|
struct SharedData {
|
69
69
|
int fd;
|
70
70
|
bool autoClose;
|
71
|
-
|
71
|
+
|
72
72
|
SharedData(int fd, bool autoClose) {
|
73
73
|
this->fd = fd;
|
74
74
|
this->autoClose = autoClose;
|
75
75
|
}
|
76
|
-
|
76
|
+
|
77
77
|
~SharedData() {
|
78
78
|
if (fd >= 0 && autoClose) {
|
79
79
|
this_thread::disable_syscall_interruption dsi;
|
80
80
|
syscalls::close(fd);
|
81
81
|
}
|
82
82
|
}
|
83
|
-
|
83
|
+
|
84
84
|
void close(bool checkErrors = true) {
|
85
85
|
if (fd >= 0) {
|
86
86
|
this_thread::disable_syscall_interruption dsi;
|
@@ -89,7 +89,7 @@ private:
|
|
89
89
|
safelyClose(theFd, !checkErrors);
|
90
90
|
}
|
91
91
|
}
|
92
|
-
|
92
|
+
|
93
93
|
void detach() {
|
94
94
|
fd = -1;
|
95
95
|
}
|
@@ -99,14 +99,14 @@ private:
|
|
99
99
|
boost::shared_ptr<SharedData> data;
|
100
100
|
|
101
101
|
public:
|
102
|
-
/**
|
102
|
+
/**
|
103
103
|
* Creates a new empty FileDescriptor instance that has no underlying
|
104
104
|
* file descriptor.
|
105
105
|
*
|
106
106
|
* @post *this == -1
|
107
107
|
*/
|
108
108
|
FileDescriptor() { }
|
109
|
-
|
109
|
+
|
110
110
|
/**
|
111
111
|
* Creates a new FileDescriptor instance with the given fd as a handle.
|
112
112
|
*
|
@@ -127,7 +127,7 @@ public:
|
|
127
127
|
errno = e;
|
128
128
|
}
|
129
129
|
}
|
130
|
-
|
130
|
+
|
131
131
|
/**
|
132
132
|
* Close the underlying file descriptor. If it was already closed, then
|
133
133
|
* nothing will happen. If there are multiple copies of this FileDescriptor
|
@@ -147,7 +147,7 @@ public:
|
|
147
147
|
data.reset();
|
148
148
|
}
|
149
149
|
}
|
150
|
-
|
150
|
+
|
151
151
|
/**
|
152
152
|
* Detach from the underlying file descriptor without closing it.
|
153
153
|
* This FileDescriptor and all copies will no longer affect the
|
@@ -166,7 +166,7 @@ public:
|
|
166
166
|
return -1;
|
167
167
|
}
|
168
168
|
}
|
169
|
-
|
169
|
+
|
170
170
|
/**
|
171
171
|
* Overloads the integer cast operator so that it will return the underlying
|
172
172
|
* file descriptor handle as an integer.
|
@@ -180,7 +180,7 @@ public:
|
|
180
180
|
return data->fd;
|
181
181
|
}
|
182
182
|
}
|
183
|
-
|
183
|
+
|
184
184
|
FileDescriptor &operator=(int fd) {
|
185
185
|
/* Make sure that the 'new' and 'delete' operators don't
|
186
186
|
* overwrite errno so that we can write code like this:
|
@@ -200,7 +200,7 @@ public:
|
|
200
200
|
errno = e;
|
201
201
|
return *this;
|
202
202
|
}
|
203
|
-
|
203
|
+
|
204
204
|
FileDescriptor &operator=(const FileDescriptor &other) {
|
205
205
|
/* Make sure that the 'delete' operator implicitly invoked by
|
206
206
|
* boost::shared_ptr doesn't overwrite errno so that we can write code
|
@@ -226,11 +226,11 @@ public:
|
|
226
226
|
class FileDescriptorPair: public pair<FileDescriptor, FileDescriptor> {
|
227
227
|
public:
|
228
228
|
FileDescriptorPair() { }
|
229
|
-
|
229
|
+
|
230
230
|
FileDescriptorPair(const FileDescriptor &a, const FileDescriptor &b)
|
231
231
|
: pair<FileDescriptor, FileDescriptor>(a, b)
|
232
232
|
{ }
|
233
|
-
|
233
|
+
|
234
234
|
FileDescriptor &operator[](int index) {
|
235
235
|
if (index == 0) {
|
236
236
|
return first;
|
@@ -257,11 +257,11 @@ class EventFd {
|
|
257
257
|
private:
|
258
258
|
int reader;
|
259
259
|
int writer;
|
260
|
-
|
260
|
+
|
261
261
|
public:
|
262
262
|
EventFd() {
|
263
263
|
int fds[2];
|
264
|
-
|
264
|
+
|
265
265
|
if (syscalls::pipe(fds) == -1) {
|
266
266
|
int e = errno;
|
267
267
|
throw SystemException("Cannot create a pipe", e);
|
@@ -269,13 +269,13 @@ public:
|
|
269
269
|
reader = fds[0];
|
270
270
|
writer = fds[1];
|
271
271
|
}
|
272
|
-
|
272
|
+
|
273
273
|
~EventFd() {
|
274
274
|
this_thread::disable_syscall_interruption dsi;
|
275
275
|
syscalls::close(reader);
|
276
276
|
syscalls::close(writer);
|
277
277
|
}
|
278
|
-
|
278
|
+
|
279
279
|
void notify() {
|
280
280
|
ssize_t ret = syscalls::write(writer, "x", 1);
|
281
281
|
if (ret == -1 && errno != EAGAIN) {
|
@@ -283,7 +283,7 @@ public:
|
|
283
283
|
throw SystemException("Cannot write notification data", e);
|
284
284
|
}
|
285
285
|
}
|
286
|
-
|
286
|
+
|
287
287
|
int fd() const {
|
288
288
|
return reader;
|
289
289
|
}
|
data/ext/common/Logging.cpp
CHANGED
data/ext/common/MessageClient.h
CHANGED
@@ -45,17 +45,17 @@ class MessageClient {
|
|
45
45
|
protected:
|
46
46
|
FileDescriptor fd;
|
47
47
|
bool shouldAutoDisconnect;
|
48
|
-
|
48
|
+
|
49
49
|
/* sendUsername() and sendPassword() exist and are virtual in order to facilitate unit testing. */
|
50
|
-
|
50
|
+
|
51
51
|
virtual void sendUsername(int fd, const StaticString &username, unsigned long long *timeout) {
|
52
52
|
writeScalarMessage(fd, username);
|
53
53
|
}
|
54
|
-
|
54
|
+
|
55
55
|
virtual void sendPassword(int fd, const StaticString &userSuppliedPassword, unsigned long long *timeout) {
|
56
56
|
writeScalarMessage(fd, userSuppliedPassword);
|
57
57
|
}
|
58
|
-
|
58
|
+
|
59
59
|
/**
|
60
60
|
* Authenticate to the server with the given username and password.
|
61
61
|
*
|
@@ -69,10 +69,10 @@ protected:
|
|
69
69
|
unsigned long long *timeout)
|
70
70
|
{
|
71
71
|
vector<string> args;
|
72
|
-
|
72
|
+
|
73
73
|
sendUsername(fd, username, timeout);
|
74
74
|
sendPassword(fd, userSuppliedPassword, timeout);
|
75
|
-
|
75
|
+
|
76
76
|
if (!readArrayMessage(fd, args, timeout)) {
|
77
77
|
throw IOException("The message server did not send an authentication response.");
|
78
78
|
} else if (args.size() != 1) {
|
@@ -81,19 +81,19 @@ protected:
|
|
81
81
|
throw SecurityException("The message server denied authentication: " + args[0]);
|
82
82
|
}
|
83
83
|
}
|
84
|
-
|
84
|
+
|
85
85
|
void checkConnection() {
|
86
86
|
if (!connected()) {
|
87
87
|
throw IOException("Not connected");
|
88
88
|
}
|
89
89
|
}
|
90
|
-
|
90
|
+
|
91
91
|
void autoDisconnect() {
|
92
92
|
if (shouldAutoDisconnect) {
|
93
93
|
fd.close(false);
|
94
94
|
}
|
95
95
|
}
|
96
|
-
|
96
|
+
|
97
97
|
public:
|
98
98
|
/**
|
99
99
|
* Create a new MessageClient object. It doesn't actually connect to the server until
|
@@ -106,9 +106,9 @@ public:
|
|
106
106
|
*/
|
107
107
|
shouldAutoDisconnect = true;
|
108
108
|
}
|
109
|
-
|
109
|
+
|
110
110
|
virtual ~MessageClient() { }
|
111
|
-
|
111
|
+
|
112
112
|
/**
|
113
113
|
* Connect to the given MessageServer. If a connection was already established,
|
114
114
|
* then the old connection will be closed and a new connection will be established.
|
@@ -134,9 +134,9 @@ public:
|
|
134
134
|
{
|
135
135
|
TRACE_POINT();
|
136
136
|
ScopeGuard g(boost::bind(&MessageClient::autoDisconnect, this));
|
137
|
-
|
137
|
+
|
138
138
|
fd = connectToServer(serverAddress.c_str());
|
139
|
-
|
139
|
+
|
140
140
|
vector<string> args;
|
141
141
|
if (!readArrayMessage(fd, args)) {
|
142
142
|
throw IOException("The message server closed the connection before sending a version identifier.");
|
@@ -149,29 +149,29 @@ public:
|
|
149
149
|
args[1] + ".";
|
150
150
|
throw IOException(message);
|
151
151
|
}
|
152
|
-
|
152
|
+
|
153
153
|
authenticate(username, userSuppliedPassword, NULL);
|
154
|
-
|
154
|
+
|
155
155
|
g.clear();
|
156
156
|
return this;
|
157
157
|
}
|
158
|
-
|
158
|
+
|
159
159
|
void disconnect() {
|
160
160
|
fd.close();
|
161
161
|
}
|
162
|
-
|
162
|
+
|
163
163
|
bool connected() const {
|
164
164
|
return fd != -1;
|
165
165
|
}
|
166
|
-
|
166
|
+
|
167
167
|
void setAutoDisconnect(bool value) {
|
168
168
|
shouldAutoDisconnect = value;
|
169
169
|
}
|
170
|
-
|
170
|
+
|
171
171
|
FileDescriptor getConnection() const {
|
172
172
|
return fd;
|
173
173
|
}
|
174
|
-
|
174
|
+
|
175
175
|
/**
|
176
176
|
* @throws SystemException
|
177
177
|
* @throws TimeoutException
|
@@ -180,7 +180,7 @@ public:
|
|
180
180
|
bool read(vector<string> &args, unsigned long long *timeout = NULL) {
|
181
181
|
return readArray(args);
|
182
182
|
}
|
183
|
-
|
183
|
+
|
184
184
|
/**
|
185
185
|
* @throws SystemException
|
186
186
|
* @throws TimeoutException
|
@@ -193,7 +193,7 @@ public:
|
|
193
193
|
g.clear();
|
194
194
|
return result;
|
195
195
|
}
|
196
|
-
|
196
|
+
|
197
197
|
/**
|
198
198
|
* @throws SystemException
|
199
199
|
* @throws SecurityException
|
@@ -212,7 +212,7 @@ public:
|
|
212
212
|
return false;
|
213
213
|
}
|
214
214
|
}
|
215
|
-
|
215
|
+
|
216
216
|
/**
|
217
217
|
* @throws SystemExeption
|
218
218
|
* @throws IOException
|
@@ -230,7 +230,7 @@ public:
|
|
230
230
|
g.clear();
|
231
231
|
return result;
|
232
232
|
}
|
233
|
-
|
233
|
+
|
234
234
|
/**
|
235
235
|
* @throws SystemException
|
236
236
|
* @throws boost::thread_interrupted
|
@@ -252,7 +252,7 @@ public:
|
|
252
252
|
throw;
|
253
253
|
}
|
254
254
|
}
|
255
|
-
|
255
|
+
|
256
256
|
/**
|
257
257
|
* @throws SystemException
|
258
258
|
* @throws TimeoutException
|
@@ -264,7 +264,7 @@ public:
|
|
264
264
|
writeScalarMessage(fd, data, size, timeout);
|
265
265
|
g.clear();
|
266
266
|
}
|
267
|
-
|
267
|
+
|
268
268
|
/**
|
269
269
|
* @throws SystemException
|
270
270
|
* @throws TimeoutException
|
@@ -276,7 +276,7 @@ public:
|
|
276
276
|
writeScalarMessage(fd, data, timeout);
|
277
277
|
g.clear();
|
278
278
|
}
|
279
|
-
|
279
|
+
|
280
280
|
/**
|
281
281
|
* @throws SystemException
|
282
282
|
* @throws boost::thread_interrupted
|
@@ -75,7 +75,7 @@
|
|
75
75
|
char buf[1024];
|
76
76
|
ssize_t size = recv(fd, buf, sizeof(buf));
|
77
77
|
size_t consumed = 0;
|
78
|
-
|
78
|
+
|
79
79
|
// ...and process it all. We only feed data to the message object
|
80
80
|
// that hasn't already been fed.
|
81
81
|
while (consumed < size) {
|
@@ -119,22 +119,22 @@ using namespace std;
|
|
119
119
|
*/
|
120
120
|
class Uint16Message {
|
121
121
|
private:
|
122
|
-
uint16_t val;
|
123
|
-
uint8_t consumed;
|
124
|
-
|
122
|
+
boost::uint16_t val;
|
123
|
+
boost::uint8_t consumed;
|
124
|
+
|
125
125
|
public:
|
126
126
|
Uint16Message() {
|
127
127
|
consumed = 0;
|
128
128
|
}
|
129
|
-
|
129
|
+
|
130
130
|
void reset() {
|
131
131
|
consumed = 0;
|
132
132
|
}
|
133
|
-
|
133
|
+
|
134
134
|
size_t feed(const char *data, size_t size) {
|
135
135
|
size_t locallyConsumed;
|
136
|
-
|
137
|
-
locallyConsumed = std::min(size, sizeof(uint16_t) - consumed);
|
136
|
+
|
137
|
+
locallyConsumed = std::min(size, sizeof(boost::uint16_t) - consumed);
|
138
138
|
memcpy((char *) &val + consumed, data, locallyConsumed);
|
139
139
|
consumed += locallyConsumed;
|
140
140
|
if (locallyConsumed > 0 && done()) {
|
@@ -142,16 +142,16 @@ public:
|
|
142
142
|
}
|
143
143
|
return locallyConsumed;
|
144
144
|
}
|
145
|
-
|
145
|
+
|
146
146
|
bool done() const {
|
147
|
-
return consumed == sizeof(uint16_t);
|
147
|
+
return consumed == sizeof(boost::uint16_t);
|
148
148
|
}
|
149
|
-
|
150
|
-
uint16_t value() const {
|
149
|
+
|
150
|
+
boost::uint16_t value() const {
|
151
151
|
return val;
|
152
152
|
}
|
153
|
-
|
154
|
-
static void generate(void *buf, uint16_t val) {
|
153
|
+
|
154
|
+
static void generate(void *buf, boost::uint16_t val) {
|
155
155
|
val = htons(val);
|
156
156
|
memcpy(buf, &val, sizeof(val));
|
157
157
|
}
|
@@ -162,22 +162,22 @@ public:
|
|
162
162
|
*/
|
163
163
|
class Uint32Message {
|
164
164
|
private:
|
165
|
-
uint32_t val;
|
166
|
-
uint8_t consumed;
|
167
|
-
|
165
|
+
boost::uint32_t val;
|
166
|
+
boost::uint8_t consumed;
|
167
|
+
|
168
168
|
public:
|
169
169
|
Uint32Message() {
|
170
170
|
consumed = 0;
|
171
171
|
}
|
172
|
-
|
172
|
+
|
173
173
|
void reset() {
|
174
174
|
consumed = 0;
|
175
175
|
}
|
176
|
-
|
176
|
+
|
177
177
|
size_t feed(const char *data, size_t size) {
|
178
178
|
size_t locallyConsumed;
|
179
|
-
|
180
|
-
locallyConsumed = std::min(size, sizeof(uint32_t) - consumed);
|
179
|
+
|
180
|
+
locallyConsumed = std::min(size, sizeof(boost::uint32_t) - consumed);
|
181
181
|
memcpy((char *) &val + consumed, data, locallyConsumed);
|
182
182
|
consumed += locallyConsumed;
|
183
183
|
if (locallyConsumed > 0 && done()) {
|
@@ -185,16 +185,16 @@ public:
|
|
185
185
|
}
|
186
186
|
return locallyConsumed;
|
187
187
|
}
|
188
|
-
|
188
|
+
|
189
189
|
bool done() const {
|
190
|
-
return consumed == sizeof(uint32_t);
|
190
|
+
return consumed == sizeof(boost::uint32_t);
|
191
191
|
}
|
192
|
-
|
193
|
-
uint32_t value() const {
|
192
|
+
|
193
|
+
boost::uint32_t value() const {
|
194
194
|
return val;
|
195
195
|
}
|
196
|
-
|
197
|
-
static void generate(void *buf, uint32_t val) {
|
196
|
+
|
197
|
+
static void generate(void *buf, boost::uint32_t val) {
|
198
198
|
val = htonl(val);
|
199
199
|
memcpy(buf, &val, sizeof(val));
|
200
200
|
}
|
@@ -208,7 +208,7 @@ public:
|
|
208
208
|
enum Error {
|
209
209
|
TOO_LARGE
|
210
210
|
};
|
211
|
-
|
211
|
+
|
212
212
|
private:
|
213
213
|
enum State {
|
214
214
|
READING_HEADER,
|
@@ -216,20 +216,20 @@ private:
|
|
216
216
|
DONE,
|
217
217
|
ERROR
|
218
218
|
};
|
219
|
-
|
220
|
-
uint16_t toReserve;
|
221
|
-
uint16_t maxSize;
|
219
|
+
|
220
|
+
boost::uint16_t toReserve;
|
221
|
+
boost::uint16_t maxSize;
|
222
222
|
Uint16Message headerReader;
|
223
|
-
uint8_t state;
|
224
|
-
uint8_t error;
|
223
|
+
boost::uint8_t state;
|
224
|
+
boost::uint8_t error;
|
225
225
|
string buffer;
|
226
226
|
vector<StaticString> result;
|
227
|
-
|
227
|
+
|
228
228
|
void parseBody(const char *data, size_t size) {
|
229
229
|
const char *start = data;
|
230
230
|
const char *terminator;
|
231
231
|
size_t rest = size;
|
232
|
-
|
232
|
+
|
233
233
|
while ((terminator = (const char *) memchr(start, '\0', rest)) != NULL) {
|
234
234
|
size_t len = terminator - start;
|
235
235
|
result.push_back(StaticString(start, len));
|
@@ -237,23 +237,23 @@ private:
|
|
237
237
|
rest = size - (start - data);
|
238
238
|
}
|
239
239
|
}
|
240
|
-
|
240
|
+
|
241
241
|
public:
|
242
242
|
ArrayMessage() {
|
243
243
|
state = READING_HEADER;
|
244
244
|
toReserve = 0;
|
245
245
|
maxSize = 0;
|
246
246
|
}
|
247
|
-
|
248
|
-
void reserve(uint16_t size) {
|
247
|
+
|
248
|
+
void reserve(boost::uint16_t size) {
|
249
249
|
toReserve = size;
|
250
250
|
result.reserve(size);
|
251
251
|
}
|
252
|
-
|
253
|
-
void setMaxSize(uint16_t size) {
|
252
|
+
|
253
|
+
void setMaxSize(boost::uint16_t size) {
|
254
254
|
maxSize = size;
|
255
255
|
}
|
256
|
-
|
256
|
+
|
257
257
|
void reset() {
|
258
258
|
state = READING_HEADER;
|
259
259
|
headerReader.reset();
|
@@ -263,14 +263,14 @@ public:
|
|
263
263
|
result.reserve(toReserve);
|
264
264
|
}
|
265
265
|
}
|
266
|
-
|
266
|
+
|
267
267
|
size_t feed(const char *data, size_t size) {
|
268
268
|
size_t consumed = 0;
|
269
|
-
|
269
|
+
|
270
270
|
while (consumed < size && !done()) {
|
271
271
|
const char *current = data + consumed;
|
272
272
|
size_t rest = size - consumed;
|
273
|
-
|
273
|
+
|
274
274
|
switch (state) {
|
275
275
|
case READING_HEADER:
|
276
276
|
consumed += headerReader.feed(current, rest);
|
@@ -311,23 +311,23 @@ public:
|
|
311
311
|
}
|
312
312
|
return consumed;
|
313
313
|
}
|
314
|
-
|
314
|
+
|
315
315
|
bool done() const {
|
316
316
|
return state == DONE || state == ERROR;
|
317
317
|
}
|
318
|
-
|
318
|
+
|
319
319
|
bool hasError() const {
|
320
320
|
return state == ERROR;
|
321
321
|
}
|
322
|
-
|
322
|
+
|
323
323
|
Error errorCode() const {
|
324
324
|
return (Error) error;
|
325
325
|
}
|
326
|
-
|
326
|
+
|
327
327
|
const vector<StaticString> &value() const {
|
328
328
|
return result;
|
329
329
|
}
|
330
|
-
|
330
|
+
|
331
331
|
/**
|
332
332
|
* Given a bunch of array items, generates an array message. The message is
|
333
333
|
* generated in the form of an array of StaticStrings which must all be written
|
@@ -346,30 +346,30 @@ public:
|
|
346
346
|
* @param outCount The number of items in <em>out</em>.
|
347
347
|
*/
|
348
348
|
static void generate(StaticString args[], unsigned int argsCount,
|
349
|
-
char headerBuf[sizeof(uint16_t)], StaticString *out, unsigned int outCount)
|
349
|
+
char headerBuf[sizeof(boost::uint16_t)], StaticString *out, unsigned int outCount)
|
350
350
|
{
|
351
351
|
if (OXT_UNLIKELY(outCount < outputSize(argsCount))) {
|
352
352
|
throw ArgumentException("outCount too small.");
|
353
353
|
}
|
354
|
-
|
354
|
+
|
355
355
|
unsigned int size = 0;
|
356
356
|
unsigned int i;
|
357
|
-
|
357
|
+
|
358
358
|
for (i = 0; i < argsCount; i++) {
|
359
359
|
size += args[i].size() + 1;
|
360
360
|
}
|
361
361
|
if (OXT_UNLIKELY(size > 0xFFFF)) {
|
362
362
|
throw ArgumentException("Data size exceeds maximum size for array messages.");
|
363
363
|
}
|
364
|
-
|
364
|
+
|
365
365
|
Uint16Message::generate(headerBuf, size);
|
366
|
-
out[0] = StaticString(headerBuf, sizeof(uint16_t));
|
366
|
+
out[0] = StaticString(headerBuf, sizeof(boost::uint16_t));
|
367
367
|
for (i = 0; i < argsCount; i++) {
|
368
368
|
out[1 + 2 * i] = args[i];
|
369
369
|
out[1 + 2 * i + 1] = StaticString("\0", 1);
|
370
370
|
}
|
371
371
|
}
|
372
|
-
|
372
|
+
|
373
373
|
static unsigned int outputSize(unsigned int argsCount) {
|
374
374
|
return argsCount * 2 + 1;
|
375
375
|
}
|
@@ -383,7 +383,7 @@ public:
|
|
383
383
|
enum Error {
|
384
384
|
TOO_LARGE
|
385
385
|
};
|
386
|
-
|
386
|
+
|
387
387
|
private:
|
388
388
|
enum State {
|
389
389
|
READING_HEADER,
|
@@ -391,24 +391,24 @@ private:
|
|
391
391
|
DONE,
|
392
392
|
ERROR
|
393
393
|
};
|
394
|
-
|
395
|
-
uint8_t state;
|
396
|
-
uint8_t error;
|
397
|
-
uint32_t maxSize;
|
394
|
+
|
395
|
+
boost::uint8_t state;
|
396
|
+
boost::uint8_t error;
|
397
|
+
boost::uint32_t maxSize;
|
398
398
|
Uint32Message headerReader;
|
399
399
|
string buffer;
|
400
400
|
StaticString result;
|
401
|
-
|
401
|
+
|
402
402
|
public:
|
403
|
-
ScalarMessage(uint32_t maxSize = 0) {
|
403
|
+
ScalarMessage(boost::uint32_t maxSize = 0) {
|
404
404
|
state = READING_HEADER;
|
405
405
|
this->maxSize = maxSize;
|
406
406
|
}
|
407
|
-
|
408
|
-
void setMaxSize(uint32_t maxSize) {
|
407
|
+
|
408
|
+
void setMaxSize(boost::uint32_t maxSize) {
|
409
409
|
this->maxSize = maxSize;
|
410
410
|
}
|
411
|
-
|
411
|
+
|
412
412
|
/**
|
413
413
|
* Resets the internal state so that this object can be used for processing
|
414
414
|
* another scalar message.
|
@@ -425,14 +425,14 @@ public:
|
|
425
425
|
headerReader.reset();
|
426
426
|
buffer.clear();
|
427
427
|
}
|
428
|
-
|
428
|
+
|
429
429
|
size_t feed(const char *data, size_t size) {
|
430
430
|
size_t consumed = 0;
|
431
|
-
|
431
|
+
|
432
432
|
while (consumed < size && !done()) {
|
433
433
|
const char *current = data + consumed;
|
434
434
|
size_t rest = size - consumed;
|
435
|
-
|
435
|
+
|
436
436
|
switch (state) {
|
437
437
|
case READING_HEADER:
|
438
438
|
consumed += headerReader.feed(current, rest);
|
@@ -473,41 +473,41 @@ public:
|
|
473
473
|
}
|
474
474
|
return consumed;
|
475
475
|
}
|
476
|
-
|
476
|
+
|
477
477
|
bool done() const {
|
478
478
|
return state == DONE || state == ERROR;
|
479
479
|
}
|
480
|
-
|
480
|
+
|
481
481
|
bool hasError() const {
|
482
482
|
return state == ERROR;
|
483
483
|
}
|
484
|
-
|
484
|
+
|
485
485
|
Error errorCode() const {
|
486
486
|
return (Error) error;
|
487
487
|
}
|
488
|
-
|
488
|
+
|
489
489
|
const StaticString &value() const {
|
490
490
|
return result;
|
491
491
|
}
|
492
|
-
|
493
|
-
static void generate(const StaticString &data, char headerBuf[sizeof(uint32_t)],
|
492
|
+
|
493
|
+
static void generate(const StaticString &data, char headerBuf[sizeof(boost::uint32_t)],
|
494
494
|
StaticString output[2])
|
495
495
|
{
|
496
496
|
if (OXT_UNLIKELY(data.size() > 0xFFFFFFFF)) {
|
497
497
|
throw ArgumentException("Data size exceeds maximum size for scalar messages.");
|
498
498
|
}
|
499
|
-
|
499
|
+
|
500
500
|
Uint32Message::generate(headerBuf, data.size());
|
501
|
-
output[0] = StaticString(headerBuf, sizeof(uint32_t));
|
501
|
+
output[0] = StaticString(headerBuf, sizeof(boost::uint32_t));
|
502
502
|
output[1] = data;
|
503
503
|
}
|
504
504
|
|
505
505
|
// output must be at least count + 1 in length
|
506
506
|
static void generate(const StaticString data[], unsigned int count,
|
507
|
-
char headerBuf[sizeof(uint32_t)], StaticString *output)
|
507
|
+
char headerBuf[sizeof(boost::uint32_t)], StaticString *output)
|
508
508
|
{
|
509
509
|
unsigned int i;
|
510
|
-
uint32_t totalSize = 0;
|
510
|
+
boost::uint32_t totalSize = 0;
|
511
511
|
|
512
512
|
for (i = 0; i < count; i++) {
|
513
513
|
if (OXT_UNLIKELY(data[i].size() > 0xFFFFFFFF)) {
|
@@ -518,7 +518,7 @@ public:
|
|
518
518
|
}
|
519
519
|
|
520
520
|
Uint32Message::generate(headerBuf, totalSize);
|
521
|
-
output[0] = StaticString(headerBuf, sizeof(uint32_t));
|
521
|
+
output[0] = StaticString(headerBuf, sizeof(boost::uint32_t));
|
522
522
|
}
|
523
523
|
};
|
524
524
|
|