passenger 5.0.25 → 5.0.26
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 +4 -4
- data/CHANGELOG +20 -0
- data/CONTRIBUTORS +1 -0
- data/build/cxx_dependency_map.rb +7338 -7104
- data/build/cxx_tests.rb +3 -3
- data/build/misc.rb +1 -0
- data/dev/index_cxx_dependencies.rb +3 -2
- data/resources/templates/standalone/config.erb +1 -1
- data/resources/templates/standalone/http.erb +1 -0
- data/resources/templates/standalone/server.erb +1 -0
- data/src/agent/Core/ApplicationPool/AbstractSession.h +83 -0
- data/src/agent/Core/ApplicationPool/Common.h +6 -4
- data/src/agent/Core/ApplicationPool/Options.h +4 -1
- data/src/agent/Core/ApplicationPool/Pool.h +2 -2
- data/src/agent/Core/ApplicationPool/Pool/AnalyticsCollection.cpp +3 -6
- data/src/agent/Core/ApplicationPool/Pool/GeneralUtils.cpp +3 -3
- data/src/agent/Core/ApplicationPool/Session.h +15 -27
- data/src/agent/Core/ApplicationPool/TestSession.h +188 -0
- data/src/agent/Core/Controller.h +15 -6
- data/src/agent/Core/Controller/CheckoutSession.cpp +13 -5
- data/src/agent/Core/Controller/ForwardResponse.cpp +20 -2
- data/src/agent/Core/Controller/Hooks.cpp +15 -2
- data/src/agent/Core/Controller/InitRequest.cpp +5 -1
- data/src/agent/Core/Controller/InitializationAndShutdown.cpp +1 -0
- data/src/agent/Core/Controller/Request.h +11 -4
- data/src/agent/Core/Controller/SendRequest.cpp +34 -13
- data/src/agent/Core/Controller/StateInspectionAndConfiguration.cpp +2 -2
- data/src/agent/Core/CoreMain.cpp +27 -1
- data/src/agent/Core/OptionParser.h +11 -1
- data/src/agent/Core/SpawningKit/DirectSpawner.h +1 -0
- data/src/agent/Core/SpawningKit/SmartSpawner.h +1 -0
- data/src/agent/Core/SpawningKit/Spawner.h +21 -1
- data/src/agent/SpawnPreparer/SpawnPreparerMain.cpp +1 -1
- data/src/agent/UstRouter/OptionParser.h +7 -1
- data/src/agent/UstRouter/UstRouterMain.cpp +27 -1
- data/src/cxx_supportlib/Algorithms/MovingAverage.h +223 -0
- data/src/cxx_supportlib/Constants.h +2 -2
- data/src/cxx_supportlib/DataStructures/StringKeyTable.h +96 -40
- data/src/cxx_supportlib/ResourceLocator.h +33 -14
- data/src/cxx_supportlib/ServerKit/Channel.h +198 -69
- data/src/cxx_supportlib/ServerKit/Errors.h +6 -1
- data/src/cxx_supportlib/ServerKit/HttpRequest.h +20 -1
- data/src/cxx_supportlib/ServerKit/HttpServer.h +124 -32
- data/src/cxx_supportlib/ServerKit/Server.h +65 -1
- data/src/cxx_supportlib/Utils/IOUtils.cpp +12 -22
- data/src/cxx_supportlib/Utils/JsonUtils.h +87 -1
- data/src/cxx_supportlib/Utils/StrIntUtils.cpp +16 -1
- data/src/cxx_supportlib/Utils/StrIntUtils.h +31 -1
- data/src/cxx_supportlib/Utils/VariantMap.h +6 -1
- data/src/cxx_supportlib/WatchdogLauncher.h +17 -9
- data/src/cxx_supportlib/vendor-copy/libuv/AUTHORS +43 -0
- data/src/cxx_supportlib/vendor-copy/libuv/ChangeLog +350 -1
- data/src/cxx_supportlib/vendor-copy/libuv/Makefile.am +9 -1
- data/src/cxx_supportlib/vendor-copy/libuv/README.md +48 -0
- data/src/cxx_supportlib/vendor-copy/libuv/checksparse.sh +1 -0
- data/src/cxx_supportlib/vendor-copy/libuv/common.gypi +5 -5
- data/src/cxx_supportlib/vendor-copy/libuv/configure.ac +2 -1
- data/src/cxx_supportlib/vendor-copy/libuv/gyp_uv.py +0 -3
- data/src/cxx_supportlib/vendor-copy/libuv/include/uv-version.h +5 -1
- data/src/cxx_supportlib/vendor-copy/libuv/include/uv.h +30 -3
- data/src/cxx_supportlib/vendor-copy/libuv/src/fs-poll.c +3 -3
- data/src/cxx_supportlib/vendor-copy/libuv/src/inet.c +0 -4
- data/src/cxx_supportlib/vendor-copy/libuv/src/queue.h +17 -1
- data/src/cxx_supportlib/vendor-copy/libuv/src/threadpool.c +10 -10
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/aix.c +84 -166
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/android-ifaddrs.c +11 -11
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/async.c +7 -1
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/atomic-ops.h +17 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/core.c +140 -21
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/darwin.c +15 -11
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/dl.c +4 -7
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/freebsd.c +52 -37
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/fs.c +181 -60
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/fsevents.c +39 -34
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/getaddrinfo.c +4 -4
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/internal.h +3 -1
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/kqueue.c +12 -4
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-core.c +38 -15
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-inotify.c +36 -8
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-syscalls.c +4 -4
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/linux-syscalls.h +2 -2
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/loop-watcher.c +6 -1
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/loop.c +28 -8
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/netbsd.c +18 -16
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/openbsd.c +18 -16
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/pipe.c +3 -3
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/process.c +18 -6
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/proctitle.c +2 -2
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/pthread-fixes.c +1 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/signal.c +2 -0
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/stream.c +47 -30
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/sunos.c +13 -11
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/tcp.c +43 -8
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/thread.c +21 -15
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/tty.c +16 -2
- data/src/cxx_supportlib/vendor-copy/libuv/src/unix/udp.c +54 -14
- data/src/cxx_supportlib/vendor-copy/libuv/src/uv-common.c +104 -21
- data/src/cxx_supportlib/vendor-copy/libuv/src/uv-common.h +14 -1
- data/src/cxx_supportlib/vendor-copy/libuv/src/version.c +1 -5
- data/src/cxx_supportlib/vendor-copy/libuv/uv.gyp +22 -1
- data/src/nginx_module/CacheLocationConfig.c +52 -0
- data/src/nginx_module/CacheLocationConfig.c.erb +13 -1
- data/src/nginx_module/Configuration.c +1 -0
- data/src/nginx_module/Configuration.h +1 -0
- data/src/nginx_module/ConfigurationCommands.c +20 -0
- data/src/nginx_module/ConfigurationFields.h +4 -0
- data/src/nginx_module/CreateLocationConfig.c +8 -0
- data/src/nginx_module/MergeLocationConfig.c +12 -0
- data/src/nginx_module/config +31 -13
- data/src/nginx_module/ngx_http_passenger_module.c +4 -0
- data/src/ruby_supportlib/phusion_passenger.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/constants.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +11 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +6 -1
- data/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb +32 -31
- data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +13 -2
- data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +1 -0
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +6 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core.rb +6 -0
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/api.rb +29 -19
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/context.rb +2 -2
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/request_reporter.rb +2 -3
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/simple_json.rb +2 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/spec_helper.rb +2 -0
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/time_point.rb +3 -17
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/transaction.rb +7 -10
- data/src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core/lib/union_station_hooks_core/utils.rb +11 -9
- metadata +5 -2
data/build/cxx_tests.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2016 Phusion Holding B.V.
|
3
3
|
#
|
4
4
|
# "Passenger", "Phusion Passenger" and "Union Station" are registered
|
5
5
|
# trademarks of Phusion Holding B.V.
|
@@ -46,8 +46,8 @@ TEST_CXX_OBJECTS = {
|
|
46
46
|
"test/cxx/Core/UnionStationTest.cpp",
|
47
47
|
"#{TEST_OUTPUT_DIR}cxx/Core/ResponseCacheTest.o" =>
|
48
48
|
"test/cxx/Core/ResponseCacheTest.cpp",
|
49
|
-
|
50
|
-
|
49
|
+
"#{TEST_OUTPUT_DIR}cxx/Core/ControllerTest.o" =>
|
50
|
+
"test/cxx/Core/ControllerTest.cpp",
|
51
51
|
|
52
52
|
"#{TEST_OUTPUT_DIR}cxx/UstRouter/TransactionTest.o" =>
|
53
53
|
"test/cxx/UstRouter/TransactionTest.cpp",
|
data/build/misc.rb
CHANGED
@@ -137,6 +137,7 @@ task :contributors do
|
|
137
137
|
entries.push "Sean Wilkinson"
|
138
138
|
entries.push "Yichun Zhang"
|
139
139
|
entries.delete "OnixGH"
|
140
|
+
entries.push "Ruslan Ermilov (NGINX Inc)"
|
140
141
|
File.open("CONTRIBUTORS", "w") do |f|
|
141
142
|
f.puts(entries.sort{ |a, b| a.downcase <=> b.downcase }.join("\n"))
|
142
143
|
end
|
@@ -191,11 +191,12 @@ end
|
|
191
191
|
|
192
192
|
def generate_full_map(basic_map)
|
193
193
|
result = {}
|
194
|
-
basic_map.
|
194
|
+
basic_map.keys.sort.each do |source_file|
|
195
|
+
deps = basic_map[source_file]
|
195
196
|
gather_results = {}
|
196
197
|
gather_all_dependencies_recursively(
|
197
198
|
source_file, basic_map, gather_results)
|
198
|
-
result[source_file] = gather_results.keys
|
199
|
+
result[source_file] = gather_results.keys.sort
|
199
200
|
end
|
200
201
|
result
|
201
202
|
end
|
@@ -33,6 +33,7 @@ passenger_user_switching off;
|
|
33
33
|
<%= nginx_http_option(:turbocaching) %>
|
34
34
|
<%= nginx_http_option(:instance_registry_dir) %>
|
35
35
|
<%= nginx_http_option(:data_buffer_dir) %>
|
36
|
+
<%= nginx_http_option(:core_file_descriptor_ulimit) %>
|
36
37
|
<%= nginx_http_option(:union_station_gateway_address) %>
|
37
38
|
<%= nginx_http_option(:union_station_gateway_port) %>
|
38
39
|
<%= nginx_http_option(:union_station_gateway_cert) %>
|
@@ -47,6 +47,7 @@ passenger_enabled on;
|
|
47
47
|
<%= nginx_option(app, :vary_turbocache_by_cookie) %>
|
48
48
|
<%= nginx_option(app, :meteor_app_settings) %>
|
49
49
|
<%= nginx_option(app, :load_shell_envvars) %>
|
50
|
+
<%= nginx_option(app, :app_file_descriptor_ulimit) %>
|
50
51
|
<%= nginx_option(app, :friendly_error_pages) %>
|
51
52
|
<%= nginx_option(app, :abort_websockets_on_process_shutdown) %>
|
52
53
|
<%= nginx_option(app, :force_max_concurrent_requests_per_process) %>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
* Copyright (c) 2016 Phusion Holding B.V.
|
4
|
+
*
|
5
|
+
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
|
+
* trademarks of Phusion Holding B.V.
|
7
|
+
*
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
13
|
+
* furnished to do so, subject to the following conditions:
|
14
|
+
*
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
16
|
+
* all copies or substantial portions of the Software.
|
17
|
+
*
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
* THE SOFTWARE.
|
25
|
+
*/
|
26
|
+
#ifndef _PASSENGER_APPLICATION_POOL_ABSTRACT_SESSION_H_
|
27
|
+
#define _PASSENGER_APPLICATION_POOL_ABSTRACT_SESSION_H_
|
28
|
+
|
29
|
+
#include <sys/types.h>
|
30
|
+
#include <boost/atomic.hpp>
|
31
|
+
#include <boost/intrusive_ptr.hpp>
|
32
|
+
#include <StaticString.h>
|
33
|
+
#include <Shared/ApplicationPoolApiKey.h>
|
34
|
+
|
35
|
+
namespace Passenger {
|
36
|
+
namespace ApplicationPool2 {
|
37
|
+
|
38
|
+
|
39
|
+
/**
|
40
|
+
* An abstract base class for Session so that unit tests can work with
|
41
|
+
* a mocked version of it.
|
42
|
+
*/
|
43
|
+
class AbstractSession {
|
44
|
+
public:
|
45
|
+
virtual ~AbstractSession() {}
|
46
|
+
|
47
|
+
virtual void ref() const = 0;
|
48
|
+
virtual void unref() const = 0;
|
49
|
+
|
50
|
+
virtual pid_t getPid() const = 0;
|
51
|
+
virtual StaticString getGupid() const = 0;
|
52
|
+
virtual StaticString getProtocol() const = 0;
|
53
|
+
virtual unsigned int getStickySessionId() const = 0;
|
54
|
+
virtual const ApiKey &getApiKey() const = 0;
|
55
|
+
virtual int fd() const = 0;
|
56
|
+
virtual bool isClosed() const = 0;
|
57
|
+
|
58
|
+
virtual void initiate(bool blocking = true) = 0;
|
59
|
+
|
60
|
+
virtual void requestOOBW() { /* Do nothing */ }
|
61
|
+
|
62
|
+
/**
|
63
|
+
* This Session object becomes fully unsable after closing.
|
64
|
+
*/
|
65
|
+
virtual void close(bool success, bool wantKeepAlive = false) = 0;
|
66
|
+
};
|
67
|
+
|
68
|
+
|
69
|
+
inline void
|
70
|
+
intrusive_ptr_add_ref(const AbstractSession *session) {
|
71
|
+
session->ref();
|
72
|
+
}
|
73
|
+
|
74
|
+
inline void
|
75
|
+
intrusive_ptr_release(const AbstractSession *session) {
|
76
|
+
session->unref();
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
} // namespace ApplicationPool2
|
81
|
+
} // namespace Passenger
|
82
|
+
|
83
|
+
#endif /* _PASSENGER_APPLICATION_POOL2_ABSTRACT_SESSION_H_ */
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2011-
|
3
|
+
* Copyright (c) 2011-2016 Phusion Holding B.V.
|
4
4
|
*
|
5
5
|
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
6
|
* trademarks of Phusion Holding B.V.
|
@@ -57,6 +57,7 @@ class Pool;
|
|
57
57
|
class Group;
|
58
58
|
class Process;
|
59
59
|
class Socket;
|
60
|
+
class AbstractSession;
|
60
61
|
class Session;
|
61
62
|
|
62
63
|
/**
|
@@ -164,6 +165,7 @@ enum RestartMethod {
|
|
164
165
|
typedef boost::shared_ptr<Pool> PoolPtr;
|
165
166
|
typedef boost::shared_ptr<Group> GroupPtr;
|
166
167
|
typedef boost::intrusive_ptr<Process> ProcessPtr;
|
168
|
+
typedef boost::intrusive_ptr<AbstractSession> AbstractSessionPtr;
|
167
169
|
typedef boost::intrusive_ptr<Session> SessionPtr;
|
168
170
|
typedef boost::shared_ptr<tracable_exception> ExceptionPtr;
|
169
171
|
typedef StringKeyTable<GroupPtr> GroupMap;
|
@@ -171,14 +173,14 @@ typedef boost::function<void (const ProcessPtr &process, DisableResult result)>
|
|
171
173
|
typedef boost::function<void ()> Callback;
|
172
174
|
|
173
175
|
struct GetCallback {
|
174
|
-
void (*func)(const
|
176
|
+
void (*func)(const AbstractSessionPtr &session, const ExceptionPtr &e, void *userData);
|
175
177
|
mutable void *userData;
|
176
178
|
|
177
|
-
void operator()(const
|
179
|
+
void operator()(const AbstractSessionPtr &session, const ExceptionPtr &e) const {
|
178
180
|
func(session, e, userData);
|
179
181
|
}
|
180
182
|
|
181
|
-
static void call(GetCallback cb, const
|
183
|
+
static void call(GetCallback cb, const AbstractSessionPtr &session, const ExceptionPtr &e) {
|
182
184
|
cb(session, e);
|
183
185
|
}
|
184
186
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-
|
3
|
+
* Copyright (c) 2010-2016 Phusion Holding B.V.
|
4
4
|
*
|
5
5
|
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
6
|
* trademarks of Phusion Holding B.V.
|
@@ -281,6 +281,8 @@ public:
|
|
281
281
|
*/
|
282
282
|
StaticString environmentVariables;
|
283
283
|
|
284
|
+
unsigned int fileDescriptorUlimit;
|
285
|
+
|
284
286
|
/**
|
285
287
|
* If set to a value that isn't -1, makes Passenger ignore the application's
|
286
288
|
* advertised socket concurrency, and believe that the concurrency should be
|
@@ -476,6 +478,7 @@ public:
|
|
476
478
|
ruby(DEFAULT_RUBY, sizeof(DEFAULT_RUBY) - 1),
|
477
479
|
python(DEFAULT_PYTHON, sizeof(DEFAULT_PYTHON) - 1),
|
478
480
|
nodejs(DEFAULT_NODEJS, sizeof(DEFAULT_NODEJS) - 1),
|
481
|
+
fileDescriptorUlimit(0),
|
479
482
|
forceMaxConcurrentRequestsPerProcess(-1),
|
480
483
|
debugger(false),
|
481
484
|
loadShellEnvvars(true),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2011-
|
3
|
+
* Copyright (c) 2011-2016 Phusion Holding B.V.
|
4
4
|
*
|
5
5
|
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
6
|
* trademarks of Phusion Holding B.V.
|
@@ -327,7 +327,7 @@ public:
|
|
327
327
|
template<typename Queue> static void assignExceptionToGetWaiters(Queue &getWaitlist,
|
328
328
|
const ExceptionPtr &exception,
|
329
329
|
boost::container::vector<Callback> &postLockActions);
|
330
|
-
static void syncGetCallback(const
|
330
|
+
static void syncGetCallback(const AbstractSessionPtr &session, const ExceptionPtr &e,
|
331
331
|
void *userData);
|
332
332
|
|
333
333
|
|
@@ -61,17 +61,14 @@ Pool::collectAnalytics(PoolPtr self) {
|
|
61
61
|
P_WARN("ERROR: " << e.what() << "\n Backtrace:\n" << e.backtrace());
|
62
62
|
}
|
63
63
|
|
64
|
-
// Sleep for about 4 seconds, aligned to seconds boundary
|
65
|
-
// for saving power on laptops.
|
66
64
|
UPDATE_TRACE_POINT();
|
67
65
|
unsigned long long currentTime = SystemTime::getUsec();
|
68
|
-
unsigned long long
|
69
|
-
roundUp<unsigned long long>(currentTime, 1000000) + 4000000;
|
66
|
+
unsigned long long sleepTime = timeToNextMultipleULL(5000000, currentTime);
|
70
67
|
P_DEBUG("Analytics collection done; next analytics collection in " <<
|
71
|
-
std::fixed << std::setprecision(3) << (
|
68
|
+
std::fixed << std::setprecision(3) << (sleepTime / 1000000.0) <<
|
72
69
|
" sec");
|
73
70
|
try {
|
74
|
-
syscalls::usleep(
|
71
|
+
syscalls::usleep(sleepTime);
|
75
72
|
} catch (const thread_interrupted &) {
|
76
73
|
break;
|
77
74
|
} catch (const tracable_exception &e) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2011-
|
3
|
+
* Copyright (c) 2011-2016 Phusion Holding B.V.
|
4
4
|
*
|
5
5
|
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
6
|
* trademarks of Phusion Holding B.V.
|
@@ -196,13 +196,13 @@ Pool::assignExceptionToGetWaiters(Queue &getWaitlist,
|
|
196
196
|
}
|
197
197
|
|
198
198
|
void
|
199
|
-
Pool::syncGetCallback(const
|
199
|
+
Pool::syncGetCallback(const AbstractSessionPtr &session, const ExceptionPtr &e,
|
200
200
|
void *userData)
|
201
201
|
{
|
202
202
|
Ticket *ticket = static_cast<Ticket *>(userData);
|
203
203
|
ScopedLock lock(ticket->syncher);
|
204
204
|
if (OXT_LIKELY(session != NULL)) {
|
205
|
-
ticket->session = session;
|
205
|
+
ticket->session = static_pointer_cast<Session>(session);
|
206
206
|
} else {
|
207
207
|
ticket->exception = e;
|
208
208
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2011-
|
3
|
+
* Copyright (c) 2011-2016 Phusion Holding B.V.
|
4
4
|
*
|
5
5
|
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
6
|
* trademarks of Phusion Holding B.V.
|
@@ -28,7 +28,6 @@
|
|
28
28
|
|
29
29
|
#include <sys/types.h>
|
30
30
|
#include <boost/atomic.hpp>
|
31
|
-
#include <boost/intrusive_ptr.hpp>
|
32
31
|
#include <oxt/macros.hpp>
|
33
32
|
#include <oxt/system_calls.hpp>
|
34
33
|
#include <oxt/backtrace.hpp>
|
@@ -38,6 +37,7 @@
|
|
38
37
|
#include <Core/ApplicationPool/BasicProcessInfo.h>
|
39
38
|
#include <Core/ApplicationPool/BasicGroupInfo.h>
|
40
39
|
#include <Core/ApplicationPool/Socket.h>
|
40
|
+
#include <Core/ApplicationPool/AbstractSession.h>
|
41
41
|
#include <Shared/ApplicationPoolApiKey.h>
|
42
42
|
|
43
43
|
namespace Passenger {
|
@@ -62,7 +62,7 @@ using namespace oxt;
|
|
62
62
|
* so in that case you must not destroy Pool before destroying all Session
|
63
63
|
* objects.
|
64
64
|
*/
|
65
|
-
class Session {
|
65
|
+
class Session: public AbstractSession {
|
66
66
|
public:
|
67
67
|
typedef void (*Callback)(Session *session);
|
68
68
|
|
@@ -151,22 +151,22 @@ public:
|
|
151
151
|
}
|
152
152
|
|
153
153
|
|
154
|
-
const ApiKey &getApiKey() const {
|
154
|
+
virtual const ApiKey &getApiKey() const {
|
155
155
|
assert(!closed);
|
156
156
|
return processInfo->groupInfo->apiKey;
|
157
157
|
}
|
158
158
|
|
159
|
-
pid_t getPid() const {
|
159
|
+
virtual pid_t getPid() const {
|
160
160
|
assert(!closed);
|
161
161
|
return processInfo->pid;
|
162
162
|
}
|
163
163
|
|
164
|
-
StaticString getGupid() const {
|
164
|
+
virtual StaticString getGupid() const {
|
165
165
|
assert(!closed);
|
166
166
|
return StaticString(processInfo->gupid, processInfo->gupidSize);
|
167
167
|
}
|
168
168
|
|
169
|
-
unsigned int getStickySessionId() const {
|
169
|
+
virtual unsigned int getStickySessionId() const {
|
170
170
|
assert(!closed);
|
171
171
|
return processInfo->stickySessionId;
|
172
172
|
}
|
@@ -176,12 +176,12 @@ public:
|
|
176
176
|
return socket;
|
177
177
|
}
|
178
178
|
|
179
|
-
StaticString getProtocol() const {
|
179
|
+
virtual StaticString getProtocol() const {
|
180
180
|
return getSocket()->protocol;
|
181
181
|
}
|
182
182
|
|
183
183
|
|
184
|
-
void initiate(bool blocking = true) {
|
184
|
+
virtual void initiate(bool blocking = true) {
|
185
185
|
assert(!closed);
|
186
186
|
ScopeGuard g(boost::bind(&Session::callOnInitiateFailure, this));
|
187
187
|
Connection connection = socket->checkoutConnection();
|
@@ -200,8 +200,7 @@ public:
|
|
200
200
|
return connection.fd != -1;
|
201
201
|
}
|
202
202
|
|
203
|
-
|
204
|
-
int fd() const {
|
203
|
+
virtual int fd() const {
|
205
204
|
assert(!closed);
|
206
205
|
return connection.fd;
|
207
206
|
}
|
@@ -209,7 +208,7 @@ public:
|
|
209
208
|
/**
|
210
209
|
* This Session object becomes fully unsable after closing.
|
211
210
|
*/
|
212
|
-
void close(bool success, bool wantKeepAlive = false) {
|
211
|
+
virtual void close(bool success, bool wantKeepAlive = false) {
|
213
212
|
if (OXT_LIKELY(initiated())) {
|
214
213
|
deinitiate(success, wantKeepAlive);
|
215
214
|
}
|
@@ -220,18 +219,18 @@ public:
|
|
220
219
|
socket = NULL;
|
221
220
|
}
|
222
221
|
|
223
|
-
bool isClosed() const {
|
222
|
+
virtual bool isClosed() const {
|
224
223
|
return closed;
|
225
224
|
}
|
226
225
|
|
227
|
-
void requestOOBW();
|
226
|
+
virtual void requestOOBW();
|
228
227
|
|
229
228
|
|
230
|
-
void ref() const {
|
229
|
+
virtual void ref() const {
|
231
230
|
refcount.fetch_add(1, boost::memory_order_relaxed);
|
232
231
|
}
|
233
232
|
|
234
|
-
void unref() const {
|
233
|
+
virtual void unref() const {
|
235
234
|
if (refcount.fetch_sub(1, boost::memory_order_release) == 1) {
|
236
235
|
boost::atomic_thread_fence(boost::memory_order_acquire);
|
237
236
|
destroySelf();
|
@@ -240,17 +239,6 @@ public:
|
|
240
239
|
};
|
241
240
|
|
242
241
|
|
243
|
-
inline void
|
244
|
-
intrusive_ptr_add_ref(const Session *session) {
|
245
|
-
session->ref();
|
246
|
-
}
|
247
|
-
|
248
|
-
inline void
|
249
|
-
intrusive_ptr_release(const Session *session) {
|
250
|
-
session->unref();
|
251
|
-
}
|
252
|
-
|
253
|
-
|
254
242
|
} // namespace ApplicationPool2
|
255
243
|
} // namespace Passenger
|
256
244
|
|
@@ -0,0 +1,188 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
* Copyright (c) 2016 Phusion Holding B.V.
|
4
|
+
*
|
5
|
+
* "Passenger", "Phusion Passenger" and "Union Station" are registered
|
6
|
+
* trademarks of Phusion Holding B.V.
|
7
|
+
*
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
13
|
+
* furnished to do so, subject to the following conditions:
|
14
|
+
*
|
15
|
+
* The above copyright notice and this permission notice shall be included in
|
16
|
+
* all copies or substantial portions of the Software.
|
17
|
+
*
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
* THE SOFTWARE.
|
25
|
+
*/
|
26
|
+
#ifndef _PASSENGER_APPLICATION_POOL_TEST_SESSION_H_
|
27
|
+
#define _PASSENGER_APPLICATION_POOL_TEST_SESSION_H_
|
28
|
+
|
29
|
+
#include <boost/thread.hpp>
|
30
|
+
#include <string>
|
31
|
+
#include <cassert>
|
32
|
+
#include <Utils/IOUtils.h>
|
33
|
+
#include <Utils/BufferedIO.h>
|
34
|
+
#include <Core/ApplicationPool/AbstractSession.h>
|
35
|
+
|
36
|
+
namespace Passenger {
|
37
|
+
namespace ApplicationPool2 {
|
38
|
+
|
39
|
+
using namespace std;
|
40
|
+
|
41
|
+
|
42
|
+
class TestSession: public AbstractSession {
|
43
|
+
private:
|
44
|
+
mutable boost::mutex syncher;
|
45
|
+
mutable unsigned int refcount;
|
46
|
+
pid_t pid;
|
47
|
+
string gupid;
|
48
|
+
string protocol;
|
49
|
+
ApiKey apiKey;
|
50
|
+
SocketPair connection;
|
51
|
+
BufferedIO peerBufferedIO;
|
52
|
+
unsigned int stickySessionId;
|
53
|
+
mutable bool closed;
|
54
|
+
mutable bool success;
|
55
|
+
mutable bool wantKeepAlive;
|
56
|
+
|
57
|
+
public:
|
58
|
+
TestSession()
|
59
|
+
: refcount(1),
|
60
|
+
pid(123),
|
61
|
+
gupid("gupid-123"),
|
62
|
+
protocol("session"),
|
63
|
+
stickySessionId(0),
|
64
|
+
closed(false),
|
65
|
+
success(false),
|
66
|
+
wantKeepAlive(false)
|
67
|
+
{ }
|
68
|
+
|
69
|
+
virtual void ref() const {
|
70
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
71
|
+
assert(refcount > 0);
|
72
|
+
refcount++;
|
73
|
+
}
|
74
|
+
|
75
|
+
virtual void unref() const {
|
76
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
77
|
+
assert(refcount > 0);
|
78
|
+
refcount--;
|
79
|
+
if (refcount == 0) {
|
80
|
+
if (!closed) {
|
81
|
+
closed = true;
|
82
|
+
success = false;
|
83
|
+
wantKeepAlive = false;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
virtual pid_t getPid() const {
|
89
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
90
|
+
return pid;
|
91
|
+
}
|
92
|
+
|
93
|
+
void setPid(pid_t p) {
|
94
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
95
|
+
pid = p;
|
96
|
+
}
|
97
|
+
|
98
|
+
virtual StaticString getGupid() const {
|
99
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
100
|
+
return gupid;
|
101
|
+
}
|
102
|
+
|
103
|
+
void setGupid(const string &v) {
|
104
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
105
|
+
gupid = v;
|
106
|
+
}
|
107
|
+
|
108
|
+
virtual StaticString getProtocol() const {
|
109
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
110
|
+
return protocol;
|
111
|
+
}
|
112
|
+
|
113
|
+
void setProtocol(const string &v) {
|
114
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
115
|
+
protocol = v;
|
116
|
+
}
|
117
|
+
|
118
|
+
virtual unsigned int getStickySessionId() const {
|
119
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
120
|
+
return stickySessionId;
|
121
|
+
}
|
122
|
+
|
123
|
+
void setStickySessionId(unsigned int v) {
|
124
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
125
|
+
stickySessionId = v;
|
126
|
+
}
|
127
|
+
|
128
|
+
virtual const ApiKey &getApiKey() const {
|
129
|
+
return apiKey;
|
130
|
+
}
|
131
|
+
|
132
|
+
virtual int fd() const {
|
133
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
134
|
+
return connection.first;
|
135
|
+
}
|
136
|
+
|
137
|
+
virtual int peerFd() const {
|
138
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
139
|
+
return connection.second;
|
140
|
+
}
|
141
|
+
|
142
|
+
virtual BufferedIO &getPeerBufferedIO() {
|
143
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
144
|
+
return peerBufferedIO;
|
145
|
+
}
|
146
|
+
|
147
|
+
virtual bool isClosed() const {
|
148
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
149
|
+
return closed;
|
150
|
+
}
|
151
|
+
|
152
|
+
bool isSuccessful() const {
|
153
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
154
|
+
return success;
|
155
|
+
}
|
156
|
+
|
157
|
+
bool wantsKeepAlive() const {
|
158
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
159
|
+
return wantKeepAlive;
|
160
|
+
}
|
161
|
+
|
162
|
+
virtual void initiate(bool blocking = true) {
|
163
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
164
|
+
connection = createUnixSocketPair(__FILE__, __LINE__);
|
165
|
+
peerBufferedIO = BufferedIO(connection.second);
|
166
|
+
if (!blocking) {
|
167
|
+
setNonBlocking(connection.first);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
virtual void close(bool _success, bool _wantKeepAlive = false) {
|
172
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
173
|
+
closed = true;
|
174
|
+
success = _success;
|
175
|
+
wantKeepAlive = _wantKeepAlive;
|
176
|
+
}
|
177
|
+
|
178
|
+
void closePeerFd() {
|
179
|
+
boost::lock_guard<boost::mutex> l(syncher);
|
180
|
+
connection.second.close();
|
181
|
+
}
|
182
|
+
};
|
183
|
+
|
184
|
+
|
185
|
+
} // namespace ApplicationPool2
|
186
|
+
} // namespace Passenger
|
187
|
+
|
188
|
+
#endif /* _PASSENGER_APPLICATION_POOL2_TEST_SESSION_H_ */
|