passenger 5.1.7 → 5.1.8

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.

Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -2
  3. data/CONTRIBUTING.md +1 -1
  4. data/build/agent.rb +1 -1
  5. data/build/cxx_tests.rb +6 -0
  6. data/build/support/cxx_dependency_map.rb +1286 -391
  7. data/build/support/general.rb +0 -26
  8. data/resources/templates/standalone/rails_asset_pipeline.erb +2 -2
  9. data/src/agent/Core/ApiServer.h +49 -44
  10. data/src/agent/Core/ApplicationPool/Pool.h +1 -1
  11. data/src/agent/Core/ApplicationPool/Process.h +1 -1
  12. data/src/agent/Core/ApplicationPool/Socket.h +1 -1
  13. data/src/agent/Core/Controller.h +16 -8
  14. data/src/agent/Core/Controller/CheckoutSession.cpp +1 -1
  15. data/src/agent/Core/Controller/Config.cpp +68 -0
  16. data/src/agent/Core/Controller/Config.h +70 -34
  17. data/src/agent/Core/Controller/ForwardResponse.cpp +5 -5
  18. data/src/agent/Core/Controller/Hooks.cpp +5 -14
  19. data/src/agent/Core/Controller/Implementation.cpp +1 -1
  20. data/src/agent/Core/Controller/InitRequest.cpp +31 -29
  21. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +4 -4
  22. data/src/agent/Core/Controller/InternalUtils.cpp +3 -3
  23. data/src/agent/Core/Controller/Miscellaneous.cpp +1 -1
  24. data/src/agent/Core/Controller/Request.h +2 -2
  25. data/src/agent/Core/Controller/SendRequest.cpp +5 -5
  26. data/src/agent/Core/Controller/StateInspection.cpp +1 -1
  27. data/src/agent/Core/Controller/TurboCaching.h +2 -2
  28. data/src/agent/Core/CoreMain.cpp +2 -2
  29. data/src/agent/Core/ResponseCache.h +3 -3
  30. data/src/agent/Core/SpawningKit/BackgroundIOCapturer.h +3 -3
  31. data/src/agent/Core/SpawningKit/DirectSpawner.h +2 -2
  32. data/src/agent/Core/SpawningKit/PipeWatcher.h +3 -3
  33. data/src/agent/Core/SpawningKit/SmartSpawner.h +2 -2
  34. data/src/agent/Core/SpawningKit/Spawner.h +1 -1
  35. data/src/agent/Core/UnionStation/Connection.h +1 -1
  36. data/src/agent/Core/UnionStation/Context.h +1 -1
  37. data/src/agent/Core/UnionStation/Transaction.h +1 -1
  38. data/src/agent/Shared/ApiServerUtils.h +73 -27
  39. data/src/agent/Shared/Base.cpp +61 -73
  40. data/src/agent/UstRouter/ApiServer.h +34 -45
  41. data/src/agent/UstRouter/Controller.h +86 -60
  42. data/src/agent/UstRouter/RemoteSender.h +1 -1
  43. data/src/agent/UstRouter/RemoteSink.h +1 -1
  44. data/src/agent/Watchdog/ApiServer.h +42 -50
  45. data/src/agent/Watchdog/WatchdogMain.cpp +1 -1
  46. data/src/apache2_module/Configuration.hpp +1 -1
  47. data/src/apache2_module/Hooks.cpp +27 -13
  48. data/src/cxx_supportlib/AppTypes.h +1 -1
  49. data/src/cxx_supportlib/BackgroundEventLoop.cpp +1 -1
  50. data/src/cxx_supportlib/ConfigKit/AsyncUtils.h +86 -0
  51. data/src/cxx_supportlib/ConfigKit/Common.h +6 -3
  52. data/src/cxx_supportlib/ConfigKit/IN_PRACTICE.md +1039 -0
  53. data/src/cxx_supportlib/ConfigKit/README.md +112 -497
  54. data/src/cxx_supportlib/ConfigKit/Schema.h +78 -15
  55. data/src/cxx_supportlib/ConfigKit/Store.h +272 -53
  56. data/src/cxx_supportlib/ConfigKit/SubComponentUtils.h +59 -0
  57. data/src/cxx_supportlib/ConfigKit/Utils.h +26 -65
  58. data/src/cxx_supportlib/ConfigKit/ValidationUtils.h +69 -0
  59. data/src/cxx_supportlib/ConfigKit/VariantMapUtils.h +7 -4
  60. data/src/cxx_supportlib/Constants.h +4 -1
  61. data/src/cxx_supportlib/Crypto.cpp +1 -1
  62. data/src/cxx_supportlib/DataStructures/StringKeyTable.h +26 -7
  63. data/src/cxx_supportlib/FileDescriptor.h +1 -1
  64. data/src/cxx_supportlib/Hooks.h +1 -1
  65. data/src/cxx_supportlib/LoggingKit/Assert.h +130 -0
  66. data/src/cxx_supportlib/LoggingKit/Config.h +97 -0
  67. data/src/cxx_supportlib/LoggingKit/Context.h +94 -0
  68. data/src/cxx_supportlib/LoggingKit/Forward.h +95 -0
  69. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +695 -0
  70. data/src/cxx_supportlib/LoggingKit/Logging.h +204 -0
  71. data/src/cxx_supportlib/LoggingKit/LoggingKit.h +33 -0
  72. data/src/cxx_supportlib/LveLoggingDecorator.h +1 -1
  73. data/src/cxx_supportlib/MemoryKit/mbuf.cpp +1 -1
  74. data/src/cxx_supportlib/RandomGenerator.h +1 -1
  75. data/src/cxx_supportlib/SafeLibev.h +1 -1
  76. data/src/cxx_supportlib/ServerKit/AcceptLoadBalancer.h +1 -1
  77. data/src/cxx_supportlib/ServerKit/Channel.h +1 -1
  78. data/src/cxx_supportlib/ServerKit/FileBufferedChannel.h +1 -1
  79. data/src/cxx_supportlib/ServerKit/FileBufferedFdSinkChannel.h +1 -1
  80. data/src/cxx_supportlib/ServerKit/HttpChunkedBodyParser.h +1 -1
  81. data/src/cxx_supportlib/ServerKit/HttpHeaderParser.h +1 -1
  82. data/src/cxx_supportlib/ServerKit/HttpServer.h +48 -15
  83. data/src/cxx_supportlib/ServerKit/Server.h +79 -52
  84. data/src/cxx_supportlib/StaticString.h +12 -0
  85. data/src/cxx_supportlib/Utils/Curl.h +16 -0
  86. data/src/cxx_supportlib/Utils/FastStringStream.h +6 -1
  87. data/src/cxx_supportlib/Utils/ScopeGuard.h +1 -1
  88. data/src/cxx_supportlib/Utils/StrIntUtils.cpp +2 -19
  89. data/src/cxx_supportlib/WatchdogLauncher.h +3 -2
  90. data/src/ruby_supportlib/phusion_passenger.rb +3 -3
  91. data/src/ruby_supportlib/phusion_passenger/common_library.rb +12 -12
  92. data/src/ruby_supportlib/phusion_passenger/constants.rb +6 -3
  93. data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +1 -0
  94. data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +1 -0
  95. metadata +14 -4
  96. data/src/cxx_supportlib/Logging.cpp +0 -295
  97. data/src/cxx_supportlib/Logging.h +0 -385
@@ -0,0 +1,204 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2010-2017 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_LOGGING_KIT_LOGGING_H_
27
+ #define _PASSENGER_LOGGING_KIT_LOGGING_H_
28
+
29
+ #include <oxt/macros.hpp>
30
+ #include <LoggingKit/Forward.h>
31
+ #include <Utils/FastStringStream.h>
32
+
33
+ namespace Passenger {
34
+ namespace LoggingKit {
35
+
36
+
37
+ /*
38
+ * The P_LOG family of macros write the given expression to the log
39
+ * output stream if the log level is sufficiently high.
40
+ */
41
+
42
+ #define P_LOG(context, level, file, line, expr) \
43
+ do { \
44
+ const Passenger::LoggingKit::ConfigRealization *_configRlz; \
45
+ if (Passenger::LoggingKit::_passesLogLevel((context), (level), &_configRlz)) { \
46
+ Passenger::FastStringStream<> _ostream; \
47
+ Passenger::LoggingKit::_prepareLogEntry(_ostream, (level), (file), (line)); \
48
+ _ostream << expr << "\n"; \
49
+ Passenger::LoggingKit::_writeLogEntry(_configRlz, _ostream.data(), _ostream.size()); \
50
+ } \
51
+ } while (false)
52
+
53
+ #define P_LOG_UNLIKELY(context, level, file, line, expr) \
54
+ do { \
55
+ const Passenger::LoggingKit::ConfigRealization *_configRlz; \
56
+ if (OXT_UNLIKELY(Passenger::LoggingKit::_passesLogLevel((context), (level), &_configRlz))) { \
57
+ Passenger::FastStringStream<> _ostream; \
58
+ Passenger::LoggingKit::_prepareLogEntry(_ostream, (level), (file), (line)); \
59
+ _ostream << expr << "\n"; \
60
+ Passenger::LoggingKit::_writeLogEntry(_configRlz, _ostream.data(), _ostream.size()); \
61
+ } \
62
+ } while (false)
63
+
64
+
65
+ /*
66
+ * P_CRITICAL, P_ERROR, P_WARN, P_NOTICE, P_INFO and P_DEBUG write
67
+ * the given expression to the log output stream if the log level is
68
+ * sufficiently high.
69
+ *
70
+ * The _WITH_POS variant of these macros allow you to specify which file
71
+ * and line it should report as the origin of the log message.
72
+ */
73
+
74
+ #define P_CRITICAL(expr) P_LOG(Passenger::LoggingKit::context, \
75
+ Passenger::LoggingKit::CRIT, __FILE__, __LINE__, expr)
76
+ #define P_CRITICAL_WITH_POS(expr, file, line) P_LOG(Passenger::LoggingKit::context, \
77
+ Passenger::LoggingKit::CRIT, file, line, expr)
78
+
79
+ #define P_ERROR(expr) P_LOG(Passenger::LoggingKit::context, \
80
+ Passenger::LoggingKit::ERROR, __FILE__, __LINE__, expr)
81
+ #define P_ERROR_WITH_POS(file, line, expr) P_LOG(Passenger::LoggingKit::context, \
82
+ Passenger::LoggingKit::ERROR, file, line, expr)
83
+
84
+ #define P_WARN(expr) P_LOG(Passenger::LoggingKit::context, \
85
+ Passenger::LoggingKit::WARN, __FILE__, __LINE__, expr)
86
+ #define P_WARN_WITH_POS(file, line, expr) P_LOG(Passenger::LoggingKit::context, \
87
+ Passenger::LoggingKit::WARN, file, line, expr)
88
+
89
+ #define P_NOTICE(expr) P_LOG(Passenger::LoggingKit::context, \
90
+ Passenger::LoggingKit::NOTICE, __FILE__, __LINE__, expr)
91
+ #define P_NOTICE_WITH_POS(file, line, expr) P_LOG(Passenger::LoggingKit::context, \
92
+ Passenger::LoggingKit::NOTICE, file, line, expr)
93
+
94
+ #define P_INFO(expr) P_LOG(Passenger::LoggingKit::context, \
95
+ Passenger::LoggingKit::INFO, __FILE__, __LINE__, expr)
96
+ #define P_INFO_WITH_POS(file, line, expr) P_LOG(Passenger::LoggingKit::context, \
97
+ Passenger::LoggingKit::INFO, file, line, expr)
98
+
99
+ #define P_DEBUG(expr) P_TRACE(1, expr)
100
+ #define P_DEBUG_WITH_POS(file, line, expr) P_TRACE_WITH_POS(1, file, line, expr)
101
+
102
+
103
+ /*
104
+ * The P_TRACE family of macros are like P_DEBUG, but allow you to set the debugging
105
+ * level.
106
+ *
107
+ * Level = 1: debug
108
+ * Level = 2: debug2
109
+ * Level = 3: debug3
110
+ */
111
+
112
+ #ifdef PASSENGER_DEBUG
113
+ #define P_TRACE(level, expr) P_LOG_UNLIKELY(Passenger::LoggingKit::context, \
114
+ Passenger::LoggingKit::Level(int(Passenger::LoggingKit::INFO) + level), \
115
+ __FILE__, __LINE__, expr)
116
+ #define P_TRACE_WITH_POS(level, file, line, expr) P_LOG_UNLIKELY(Passenger::LoggingKit::context, \
117
+ Passenger::LoggingKit::Level(int(Passenger::LoggingKit::INFO) + level), \
118
+ file, line, expr)
119
+ #else
120
+ #define P_TRACE(level, expr) do { /* nothing */ } while (false)
121
+ #define P_TRACE_WITH_POS(level, file, line, expr) do { /* nothing */ } while (false)
122
+ #endif
123
+
124
+
125
+ /**
126
+ * Log the fact that a file descriptor has been opened.
127
+ */
128
+ #define P_LOG_FILE_DESCRIPTOR_OPEN(fd) \
129
+ P_LOG_FILE_DESCRIPTOR_OPEN3(fd, __FILE__, __LINE__)
130
+ #define P_LOG_FILE_DESCRIPTOR_OPEN2(fd, expr) \
131
+ P_LOG_FILE_DESCRIPTOR_OPEN4(fd, __FILE__, __LINE__, expr)
132
+ #define P_LOG_FILE_DESCRIPTOR_OPEN3(fd, file, line) \
133
+ do { \
134
+ const Passenger::LoggingKit::ConfigRealization *_configRlz; \
135
+ if (Passenger::LoggingKit::_shouldLogFileDescriptors(Passenger::LoggingKit::context, \
136
+ &_configRlz)) \
137
+ { \
138
+ Passenger::FastStringStream<> _ostream; \
139
+ Passenger::LoggingKit::_prepareLogEntry(_ostream, \
140
+ Passenger::LoggingKit::DEBUG, file, line); \
141
+ _ostream << "File descriptor opened: " << fd << "\n"; \
142
+ Passenger::LoggingKit::_writeFileDescriptorLogEntry(_configRlz, \
143
+ _ostream.data(), _ostream.size()); \
144
+ } \
145
+ } while (false)
146
+ #define P_LOG_FILE_DESCRIPTOR_OPEN4(fd, file, line, expr) \
147
+ do { \
148
+ P_LOG_FILE_DESCRIPTOR_OPEN3(fd, file, line); \
149
+ P_LOG_FILE_DESCRIPTOR_PURPOSE(fd, expr); \
150
+ } while (false)
151
+
152
+ /**
153
+ * Log the purpose of a file descriptor that was recently logged with
154
+ * P_LOG_FILE_DESCRIPTOR_OPEN(). You should include information that
155
+ * allows a reader to find out what a file descriptor is for.
156
+ */
157
+ #define P_LOG_FILE_DESCRIPTOR_PURPOSE(fd, expr) \
158
+ do { \
159
+ const Passenger::LoggingKit::ConfigRealization *_configRlz; \
160
+ if (Passenger::LoggingKit::_shouldLogFileDescriptors(Passenger::LoggingKit::context, \
161
+ &_configRlz)) \
162
+ { \
163
+ Passenger::FastStringStream<> _ostream; \
164
+ Passenger::LoggingKit::_prepareLogEntry(_ostream, \
165
+ Passenger::LoggingKit::DEBUG, __FILE__, __LINE__); \
166
+ _ostream << "File descriptor purpose: " << fd << ": " << expr << "\n"; \
167
+ Passenger::LoggingKit::_writeFileDescriptorLogEntry(_configRlz, \
168
+ _ostream.data(), _ostream.size()); \
169
+ } \
170
+ } while (false)
171
+
172
+ /**
173
+ * Log the fact that a file descriptor has been closed.
174
+ */
175
+ #define P_LOG_FILE_DESCRIPTOR_CLOSE(fd) \
176
+ do { \
177
+ const Passenger::LoggingKit::ConfigRealization *_configRlz; \
178
+ if (Passenger::LoggingKit::_shouldLogFileDescriptors(Passenger::LoggingKit::context, \
179
+ &_configRlz)) \
180
+ { \
181
+ Passenger::FastStringStream<> _ostream; \
182
+ Passenger::LoggingKit::_prepareLogEntry(_ostream, \
183
+ Passenger::LoggingKit::DEBUG, __FILE__, __LINE__); \
184
+ _ostream << "File descriptor closed: " << fd << "\n"; \
185
+ Passenger::LoggingKit::_writeFileDescriptorLogEntry(_configRlz, \
186
+ _ostream.data(), _ostream.size()); \
187
+ } \
188
+ } while (false)
189
+
190
+
191
+ /**
192
+ * Logs a message that was received from an application's stdout/stderr.
193
+ *
194
+ * @param pid The application's PID.
195
+ * @param channelName "stdout" or "stderr".
196
+ * @param message The message that was received.
197
+ */
198
+ void logAppOutput(pid_t pid, const char *channelName, const char *message, unsigned int size);
199
+
200
+
201
+ } // namespace LoggingKit
202
+ } // namespace Passenger
203
+
204
+ #endif /* _PASSENGER_LOGGING_KIT_LOGGING_H_ */
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2017 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_LOGGING_KIT_H_
27
+ #define _PASSENGER_LOGGING_KIT_H_
28
+
29
+ #include <LoggingKit/Forward.h>
30
+ #include <LoggingKit/Logging.h>
31
+ #include <LoggingKit/Assert.h>
32
+
33
+ #endif /* _PASSENGER_LOGGING_KIT_H_ */
@@ -26,7 +26,7 @@
26
26
  #ifndef _PASSENGER_LVE_LOGGING_DECORATOR_H_
27
27
  #define _PASSENGER_LVE_LOGGING_DECORATOR_H_
28
28
 
29
- #include <Logging.h>
29
+ #include <LoggingKit/LoggingKit.h>
30
30
  #include <adhoc_lve.h>
31
31
  #include <string>
32
32
  #include <sys/types.h>
@@ -24,7 +24,7 @@
24
24
  #include <algorithm>
25
25
  #include <ostream>
26
26
  #include <MemoryKit/mbuf.h>
27
- #include <Logging.h>
27
+ #include <LoggingKit/LoggingKit.h>
28
28
  #include <StaticString.h>
29
29
  #include <Utils/StrIntUtils.h>
30
30
 
@@ -32,7 +32,7 @@
32
32
  #include <boost/shared_ptr.hpp>
33
33
  #include <oxt/system_calls.hpp>
34
34
 
35
- #include <Logging.h>
35
+ #include <LoggingKit/LoggingKit.h>
36
36
  #include <StaticString.h>
37
37
  #include <Exceptions.h>
38
38
  #include <Utils/StrIntUtils.h>
@@ -36,7 +36,7 @@
36
36
  #include <boost/function.hpp>
37
37
  #include <boost/bind.hpp>
38
38
  #include <oxt/thread.hpp>
39
- #include <Logging.h>
39
+ #include <LoggingKit/LoggingKit.h>
40
40
 
41
41
  namespace Passenger {
42
42
 
@@ -42,7 +42,7 @@
42
42
  #include <poll.h>
43
43
 
44
44
  #include <Constants.h>
45
- #include <Logging.h>
45
+ #include <LoggingKit/LoggingKit.h>
46
46
  #include <Utils.h>
47
47
  #include <Utils/IOUtils.h>
48
48
 
@@ -36,7 +36,7 @@
36
36
  #include <ServerKit/Context.h>
37
37
  #include <ServerKit/Hooks.h>
38
38
  #include <MemoryKit/mbuf.h>
39
- #include <Logging.h>
39
+ #include <LoggingKit/LoggingKit.h>
40
40
  #include <Utils/StrIntUtils.h>
41
41
 
42
42
  namespace Passenger {
@@ -41,7 +41,7 @@
41
41
  #include <utility>
42
42
  #include <string>
43
43
  #include <deque>
44
- #include <Logging.h>
44
+ #include <LoggingKit/LoggingKit.h>
45
45
  #include <ServerKit/Context.h>
46
46
  #include <ServerKit/Errors.h>
47
47
  #include <ServerKit/Channel.h>
@@ -29,7 +29,7 @@
29
29
  #include <oxt/macros.hpp>
30
30
  #include <sys/types.h>
31
31
  #include <unistd.h>
32
- #include <Logging.h>
32
+ #include <LoggingKit/LoggingKit.h>
33
33
  #include <MemoryKit/mbuf.h>
34
34
  #include <ServerKit/FileBufferedChannel.h>
35
35
 
@@ -42,7 +42,7 @@ using namespace std;
42
42
 
43
43
  #define CBP_DEBUG(expr) \
44
44
  do { \
45
- if (OXT_UNLIKELY(Passenger::getLogLevel() >= LVL_DEBUG3)) { \
45
+ if (OXT_UNLIKELY(Passenger::LoggingKit::getLevel() >= Passenger::LoggingKit::DEBUG3)) { \
46
46
  char _buf[256]; \
47
47
  unsigned int size = loggingPrefixFormatter(_buf, sizeof(_buf), userData); \
48
48
  P_TRACE(3, StaticString(_buf, size) << expr); \
@@ -37,7 +37,7 @@
37
37
  #include <ServerKit/HttpHeaderParserState.h>
38
38
  #include <DataStructures/LString.h>
39
39
  #include <DataStructures/HashedStaticString.h>
40
- #include <Logging.h>
40
+ #include <LoggingKit/LoggingKit.h>
41
41
  #include <Utils/StrIntUtils.h>
42
42
  #include <Utils/Hasher.h>
43
43
 
@@ -35,7 +35,7 @@
35
35
  #include <cmath>
36
36
  #include <cassert>
37
37
  #include <pthread.h>
38
- #include <Logging.h>
38
+ #include <LoggingKit/LoggingKit.h>
39
39
  #include <ServerKit/Server.h>
40
40
  #include <ServerKit/HttpClient.h>
41
41
  #include <ServerKit/HttpRequest.h>
@@ -83,6 +83,23 @@ public:
83
83
  }
84
84
  };
85
85
 
86
+ struct HttpServerConfigRealization {
87
+ unsigned int requestFreelistLimit;
88
+
89
+ HttpServerConfigRealization(const ConfigKit::Store &config)
90
+ : requestFreelistLimit(config["request_freelist_limit"].asUInt())
91
+ { }
92
+
93
+ void swap(HttpServerConfigRealization &other) BOOST_NOEXCEPT_OR_NOTHROW {
94
+ std::swap(requestFreelistLimit, other.requestFreelistLimit);
95
+ }
96
+ };
97
+
98
+ struct HttpServerConfigChangeRequest {
99
+ BaseServerConfigChangeRequest forParent;
100
+ boost::scoped_ptr<HttpServerConfigRealization> configRlz;
101
+ };
102
+
86
103
 
87
104
  template< typename DerivedServer, typename Client = HttpClient<HttpRequest> >
88
105
  class HttpServer: public BaseServer<DerivedServer, Client> {
@@ -91,8 +108,10 @@ public:
91
108
  typedef HttpRequestRef<DerivedServer, Request> RequestRef;
92
109
  STAILQ_HEAD(FreeRequestList, Request);
93
110
 
111
+ typedef HttpServerConfigChangeRequest ConfigChangeRequest;
112
+
94
113
  FreeRequestList freeRequests;
95
- unsigned int freeRequestCount, requestFreelistLimit;
114
+ unsigned int freeRequestCount;
96
115
  unsigned long totalRequestsBegun, lastTotalRequestsBegun;
97
116
  double requestBeginSpeed1m, requestBeginSpeed1h;
98
117
 
@@ -126,6 +145,11 @@ private:
126
145
  friend class RequestHooksImpl;
127
146
 
128
147
 
148
+ /***** Configuration *****/
149
+
150
+ HttpServerConfigRealization configRlz;
151
+
152
+
129
153
  /***** Working state *****/
130
154
 
131
155
  RequestHooksImpl requestHooksImpl;
@@ -196,7 +220,7 @@ private:
196
220
  }
197
221
 
198
222
  bool addRequestToFreelist(Request *request) {
199
- if (freeRequestCount < requestFreelistLimit) {
223
+ if (freeRequestCount < configRlz.requestFreelistLimit) {
200
224
  STAILQ_INSERT_HEAD(&freeRequests, request, nextRequest.freeRequest);
201
225
  freeRequestCount++;
202
226
  request->refcount.store(1, boost::memory_order_relaxed);
@@ -856,13 +880,13 @@ protected:
856
880
  return false;
857
881
  }
858
882
 
859
- virtual PassengerLogLevel getClientOutputErrorDisconnectionLogLevel(
883
+ virtual LoggingKit::Level getClientOutputErrorDisconnectionLogLevel(
860
884
  Client *client, int errcode) const
861
885
  {
862
886
  if (errcode == EPIPE || errcode == ECONNRESET) {
863
- return LVL_INFO;
887
+ return LoggingKit::INFO;
864
888
  } else {
865
- return LVL_WARN;
889
+ return LoggingKit::WARN;
866
890
  }
867
891
  }
868
892
 
@@ -941,13 +965,6 @@ protected:
941
965
  req->bodyChannel.deinitialize();
942
966
  }
943
967
 
944
- virtual void onConfigChange(const ConfigKit::Store *oldConfig) {
945
- ParentClass::onConfigChange(oldConfig);
946
- const ConfigKit::Store &config = this->config;
947
-
948
- requestFreelistLimit = config["request_freelist_limit"].asUInt();
949
- }
950
-
951
968
 
952
969
  /***** Misc *****/
953
970
 
@@ -961,11 +978,11 @@ public:
961
978
  const Json::Value &initialConfig = Json::Value())
962
979
  : ParentClass(context, schema, initialConfig),
963
980
  freeRequestCount(0),
964
- requestFreelistLimit(1024),
965
981
  totalRequestsBegun(0),
966
982
  lastTotalRequestsBegun(0),
967
983
  requestBeginSpeed1m(-1),
968
984
  requestBeginSpeed1h(-1),
985
+ configRlz(ParentClass::config),
969
986
  headerParserStatePool(16, 256)
970
987
  {
971
988
  STAILQ_INIT(&freeRequests);
@@ -974,7 +991,7 @@ public:
974
991
 
975
992
  /***** Server management *****/
976
993
 
977
- virtual void compact(int logLevel = LVL_NOTICE) {
994
+ virtual void compact(LoggingKit::Level logLevel = LoggingKit::NOTICE) {
978
995
  ParentClass::compact();
979
996
  unsigned int count = freeRequestCount;
980
997
 
@@ -1210,6 +1227,22 @@ public:
1210
1227
 
1211
1228
  /***** Configuration and introspection *****/
1212
1229
 
1230
+ bool prepareConfigChange(const Json::Value &updates,
1231
+ vector<ConfigKit::Error> &errors, HttpServerConfigChangeRequest &req)
1232
+ {
1233
+ if (ParentClass::prepareConfigChange(updates, errors, req.forParent)) {
1234
+ req.configRlz.reset(new HttpServerConfigRealization(*req.forParent.config));
1235
+ }
1236
+ return errors.empty();
1237
+ }
1238
+
1239
+ void commitConfigChange(HttpServerConfigChangeRequest &req)
1240
+ BOOST_NOEXCEPT_OR_NOTHROW
1241
+ {
1242
+ ParentClass::commitConfigChange(req.forParent);
1243
+ configRlz.swap(*req.configRlz);
1244
+ }
1245
+
1213
1246
  virtual Json::Value inspectStateAsJson() const {
1214
1247
  Json::Value doc = ParentClass::inspectStateAsJson();
1215
1248
  doc["free_request_count"] = freeRequestCount;