passenger 5.3.4 → 5.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/build/cxx_tests.rb +12 -1
  5. data/build/misc.rb +2 -1
  6. data/build/packaging.rb +2 -0
  7. data/build/support/cplusplus.rb +2 -2
  8. data/build/support/cxx_dependency_map.rb +653 -383
  9. data/dev/configkit-schemas/index.json +105 -3
  10. data/dev/show-latest-crashlog-dir +27 -0
  11. data/resources/templates/standalone/http.erb +2 -0
  12. data/src/agent/Core/AdminPanelConnector.h +2 -2
  13. data/src/agent/Core/ApplicationPool/Context.h +5 -1
  14. data/src/agent/Core/ApplicationPool/Group.h +2 -0
  15. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +5 -0
  16. data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +2 -1
  17. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
  18. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +12 -19
  19. data/src/agent/Core/ApplicationPool/Options.h +35 -31
  20. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +2 -1
  21. data/src/agent/Core/ApplicationPool/Socket.h +1 -1
  22. data/src/agent/Core/Config.h +38 -7
  23. data/src/agent/Core/ConfigChange.cpp +13 -1
  24. data/src/agent/Core/Controller.h +3 -1
  25. data/src/agent/Core/Controller/Config.h +14 -11
  26. data/src/agent/Core/Controller/InitRequest.cpp +6 -5
  27. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +3 -0
  28. data/src/agent/Core/CoreMain.cpp +149 -34
  29. data/src/agent/Core/OptionParser.h +12 -1
  30. data/src/agent/Core/SpawningKit/Config.h +1 -1
  31. data/src/agent/Core/SpawningKit/Context.h +7 -1
  32. data/src/agent/Core/SpawningKit/Exceptions.h +15 -12
  33. data/src/agent/Core/SpawningKit/README.md +34 -17
  34. data/src/agent/Core/SpawningKit/Spawner.h +5 -3
  35. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +5 -2
  36. data/src/agent/Core/TelemetryCollector.h +674 -0
  37. data/src/agent/Shared/Fundamentals/AbortHandler.cpp +309 -83
  38. data/src/agent/Shared/Fundamentals/AbortHandler.h +18 -3
  39. data/src/agent/Watchdog/Config.h +21 -4
  40. data/src/agent/Watchdog/WatchdogMain.cpp +4 -1
  41. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +10 -0
  42. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  43. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +30 -0
  44. data/src/apache2_module/DirectoryMapper.h +24 -36
  45. data/src/apache2_module/Hooks.cpp +13 -5
  46. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +20 -0
  47. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +24 -0
  48. data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +136 -0
  49. data/src/cxx_supportlib/AppTypeDetector/CBindings.h +73 -0
  50. data/src/cxx_supportlib/{AppTypes.h → AppTypeDetector/Detector.h} +59 -132
  51. data/src/cxx_supportlib/ConfigKit/README.md +90 -2
  52. data/src/cxx_supportlib/ConfigKit/Schema.h +58 -13
  53. data/src/cxx_supportlib/ConfigKit/Store.h +128 -4
  54. data/src/cxx_supportlib/Constants.h +1 -1
  55. data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +3 -3
  56. data/src/cxx_supportlib/ProcessManagement/Ruby.h +7 -2
  57. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +14 -7
  58. data/src/cxx_supportlib/ProcessManagement/Spawn.h +21 -2
  59. data/src/cxx_supportlib/ResourceLocator.h +1 -1
  60. data/src/cxx_supportlib/ServerKit/ClientRef.h +17 -7
  61. data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +17 -7
  62. data/src/cxx_supportlib/Utils/IOUtils.cpp +2 -1
  63. data/src/cxx_supportlib/Utils/ProcessMetricsCollector.h +9 -6
  64. data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +85 -0
  65. data/src/cxx_supportlib/WrapperRegistry/CBindings.h +56 -0
  66. data/src/cxx_supportlib/WrapperRegistry/Entry.h +112 -0
  67. data/src/cxx_supportlib/WrapperRegistry/README.md +37 -0
  68. data/src/cxx_supportlib/WrapperRegistry/Registry.h +309 -0
  69. data/src/helper-scripts/download_binaries/extconf.rb +6 -2
  70. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +16 -0
  71. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +6 -0
  72. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +24 -0
  73. data/src/nginx_module/ContentHandler.c +34 -13
  74. data/src/nginx_module/ContentHandler.h +3 -3
  75. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +11 -0
  76. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +23 -0
  77. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +8 -0
  78. data/src/nginx_module/config +2 -1
  79. data/src/nginx_module/ngx_http_passenger_module.c +9 -3
  80. data/src/nginx_module/ngx_http_passenger_module.h +4 -2
  81. data/src/ruby_supportlib/phusion_passenger.rb +2 -1
  82. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +13 -0
  83. data/src/ruby_supportlib/phusion_passenger/common_library.rb +8 -5
  84. data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +6 -2
  85. data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +6 -2
  86. data/src/ruby_supportlib/phusion_passenger/native_support.rb +7 -3
  87. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +15 -0
  88. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +11 -1
  89. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +3 -1
  90. metadata +12 -4
  91. data/src/cxx_supportlib/AppTypes.cpp +0 -109
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2010-2018 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,6 +28,7 @@
28
28
 
29
29
  #include <string>
30
30
  #include <vector>
31
+ #include <limits>
31
32
  #include <cstddef>
32
33
 
33
34
  namespace Passenger {
@@ -35,6 +36,7 @@ namespace Passenger {
35
36
  using namespace std;
36
37
 
37
38
  class ResourceLocator;
39
+ struct SubprocessOutput;
38
40
 
39
41
 
40
42
  /**
@@ -48,12 +50,15 @@ class ResourceLocator;
48
50
  * When unable to waitpid() the child process because of an ECHILD
49
51
  * or ESRCH, this will be set to -1.
50
52
  * @param output The output of the child process will be stored here, if non-NULL.
53
+ * @param maxOutputSize The maximum number of output bytes to read. Only applicable if
54
+ * `output` is non-NULL.
51
55
  * @throws RuntimeException
52
56
  * @throws SystemException
53
57
  */
54
58
  void runInternalRubyTool(const ResourceLocator &resourceLocator,
55
59
  const string &ruby, const vector<string> &args,
56
- int *status = NULL, string *output = NULL);
60
+ int *status = NULL, SubprocessOutput *output = NULL,
61
+ size_t maxOutputSize = std::numeric_limits<size_t>::max());
57
62
 
58
63
 
59
64
  } // namespace Passenger
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2010-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -33,6 +33,7 @@
33
33
  #include <boost/thread.hpp>
34
34
  #include <oxt/system_calls.hpp>
35
35
  #include <string>
36
+ #include <algorithm>
36
37
  #include <cerrno>
37
38
 
38
39
  #include <ProcessManagement/Spawn.h>
@@ -110,7 +111,7 @@ runCommand(const char **command, SubprocessInfo &info, bool wait, bool killSubpr
110
111
 
111
112
  void
112
113
  runCommandAndCaptureOutput(const char **command, SubprocessInfo &info,
113
- string &output, bool killSubprocessOnInterruption,
114
+ SubprocessOutput &output, size_t maxSize, bool killSubprocessOnInterruption,
114
115
  const boost::function<void ()> &afterFork,
115
116
  const boost::function<void (const char **command, int errcode)> &onExecFail)
116
117
  {
@@ -140,15 +141,17 @@ runCommandAndCaptureOutput(const char **command, SubprocessInfo &info,
140
141
  e = errno;
141
142
  throw SystemException("Cannot fork() a new process", e);
142
143
  } else {
143
- bool done = false;
144
+ size_t totalRead = 0;
144
145
 
146
+ output.eof = false;
145
147
  p[1].close();
146
- while (!done) {
148
+ while (totalRead < maxSize) {
147
149
  char buf[1024 * 4];
148
150
  ssize_t ret;
149
151
 
150
152
  try {
151
- ret = syscalls::read(p[0], buf, sizeof(buf));
153
+ ret = syscalls::read(p[0], buf,
154
+ std::min<size_t>(sizeof(buf), maxSize - totalRead));
152
155
  } catch (const boost::thread_interrupted &) {
153
156
  if (killSubprocessOnInterruption) {
154
157
  boost::this_thread::disable_syscall_interruption dsi;
@@ -166,9 +169,13 @@ runCommandAndCaptureOutput(const char **command, SubprocessInfo &info,
166
169
  }
167
170
  throw SystemException(string("Cannot read output from the '") +
168
171
  command[0] + "' command", e);
172
+ } else if (ret == 0) {
173
+ output.eof = true;
174
+ break;
175
+ } else {
176
+ totalRead += ret;
177
+ output.data.append(buf, ret);
169
178
  }
170
- done = ret == 0;
171
- output.append(buf, ret);
172
179
  }
173
180
  p[0].close();
174
181
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2010-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2010-2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -67,6 +67,24 @@ struct SubprocessInfo {
67
67
  { }
68
68
  };
69
69
 
70
+ struct SubprocessOutput {
71
+ /**
72
+ * The read subprocess output data.
73
+ */
74
+ string data;
75
+
76
+ /**
77
+ * Whether the entire file has been read. If false, then it
78
+ * means there is more data than specified through the `maxSize`
79
+ * parameter.
80
+ */
81
+ bool eof;
82
+
83
+ SubprocessOutput()
84
+ : eof(false)
85
+ { }
86
+ };
87
+
70
88
 
71
89
  // See ProcessManagement/Utils.h for definition
72
90
  void printExecError(const char **command, int errcode);
@@ -132,6 +150,7 @@ void runCommand(const char **command, SubprocessInfo &info,
132
150
  *
133
151
  * @param command The argument array to pass to execvp(). Must be null-terminated.
134
152
  * @param info
153
+ * @param maxSize The maximum number of output bytes to read.
135
154
  * @param killSubprocessOnInterruption Whether to automatically kill the subprocess
136
155
  * when this function is interrupted.
137
156
  * @param afterFork A function object to be called right after forking.
@@ -140,7 +159,7 @@ void runCommand(const char **command, SubprocessInfo &info,
140
159
  * @throws boost::thread_interrupted
141
160
  */
142
161
  void runCommandAndCaptureOutput(const char **command, SubprocessInfo &info,
143
- string &output, bool killSubprocessOnInterruption = true,
162
+ SubprocessOutput &output, size_t maxSize, bool killSubprocessOnInterruption = true,
144
163
  const boost::function<void ()> &afterFork = boost::function<void ()>(),
145
164
  const boost::function<void (const char **command, int errcode)> &onExecFail = printExecError);
146
165
 
@@ -170,7 +170,7 @@ public:
170
170
  return buildSystemDir;
171
171
  }
172
172
 
173
- string findSupportBinary(const string &name) {
173
+ string findSupportBinary(const string &name) const {
174
174
  string path = getSupportBinariesDir() + "/" + name;
175
175
  bool found;
176
176
  try {
@@ -80,9 +80,13 @@ public:
80
80
 
81
81
  explicit
82
82
  ClientRef(BOOST_RV_REF(ClientRef) ref)
83
- : client(ref.client)
83
+ : client(ref.client),
84
+ file(ref.file),
85
+ line(ref.line)
84
86
  {
85
87
  ref.client = NULL;
88
+ ref.file = NULL;
89
+ ref.line = 0;
86
90
  }
87
91
 
88
92
  ~ClientRef() {
@@ -96,7 +100,7 @@ public:
96
100
  }
97
101
 
98
102
  ClientRef &operator=(BOOST_COPY_ASSIGN_REF(ClientRef) ref) {
99
- if (client == ref.client) {
103
+ if (this != &ref) {
100
104
  Client *oldClient = client;
101
105
  const char *oldFile = file;
102
106
  unsigned int oldLine = line;
@@ -114,11 +118,17 @@ public:
114
118
  }
115
119
 
116
120
  ClientRef &operator=(BOOST_RV_REF(ClientRef) ref) {
117
- Client *oldClient = client;
118
- client = ref.client;
119
- ref.client = NULL;
120
- if (oldClient != NULL) {
121
- getServer(oldClient)->_unrefClient(oldClient, file, line);
121
+ if (this != &ref) {
122
+ Client *oldClient = client;
123
+ client = ref.client;
124
+ file = ref.file;
125
+ line = ref.line;
126
+ ref.client = NULL;
127
+ ref.file = NULL;
128
+ ref.line = 0;
129
+ if (oldClient != NULL) {
130
+ getServer(oldClient)->_unrefClient(oldClient, file, line);
131
+ }
122
132
  }
123
133
  return *this;
124
134
  }
@@ -80,9 +80,13 @@ public:
80
80
 
81
81
  explicit
82
82
  HttpRequestRef(BOOST_RV_REF(HttpRequestRef) ref)
83
- : request(ref.request)
83
+ : request(ref.request),
84
+ file(ref.file),
85
+ line(ref.line)
84
86
  {
85
87
  ref.request = NULL;
88
+ ref.file = NULL;
89
+ ref.line = 0;
86
90
  }
87
91
 
88
92
  ~HttpRequestRef() {
@@ -96,7 +100,7 @@ public:
96
100
  }
97
101
 
98
102
  HttpRequestRef &operator=(BOOST_COPY_ASSIGN_REF(HttpRequestRef) ref) {
99
- if (request == ref.request) {
103
+ if (this != &ref) {
100
104
  Request *oldRequest = request;
101
105
  const char *oldFile = file;
102
106
  unsigned int oldLine = line;
@@ -114,11 +118,17 @@ public:
114
118
  }
115
119
 
116
120
  HttpRequestRef &operator=(BOOST_RV_REF(HttpRequestRef) ref) {
117
- Request *oldRequest = request;
118
- request = ref.request;
119
- ref.request = NULL;
120
- if (oldRequest != NULL) {
121
- getServer(oldRequest)->_unrefRequest(oldRequest, file, line);
121
+ if (this != &ref) {
122
+ Request *oldRequest = request;
123
+ request = ref.request;
124
+ file = ref.file;
125
+ line = ref.line;
126
+ ref.request = NULL;
127
+ ref.file = NULL;
128
+ ref.line = 0;
129
+ if (oldRequest != NULL) {
130
+ getServer(oldRequest)->_unrefRequest(oldRequest, file, line);
131
+ }
122
132
  }
123
133
  return *this;
124
134
  }
@@ -1363,7 +1363,8 @@ readAll(int fd, size_t maxSize) {
1363
1363
 
1364
1364
  while (result.size() < maxSize) {
1365
1365
  do {
1366
- ret = read(fd, buf, sizeof(buf));
1366
+ ret = read(fd, buf, std::min<size_t>(sizeof(buf),
1367
+ maxSize - result.size()));
1367
1368
  } while (ret == -1 && errno == EINTR);
1368
1369
  if (ret == 0) {
1369
1370
  eofReached = true;
@@ -321,18 +321,21 @@ public:
321
321
  NULL
322
322
  };
323
323
 
324
- string psOutput = this->psOutput;
325
- if (psOutput.empty()) {
324
+ SubprocessOutput psOutput;
325
+ psOutput.data = this->psOutput;
326
+ if (psOutput.data.empty()) {
326
327
  SubprocessInfo info;
327
- runCommandAndCaptureOutput(command, info, psOutput, true, afterFork);
328
- if (psOutput.empty()) {
328
+ runCommandAndCaptureOutput(command, info, psOutput,
329
+ 1024 * 1024, true, afterFork);
330
+ if (psOutput.data.empty()) {
329
331
  throw RuntimeException("The 'ps' command failed");
330
332
  }
331
333
  }
332
334
  pidsArg.resize(0);
333
335
  fmtArg.resize(0);
334
- ProcessMetricMap result = parsePsOutput<Collection, ConstIterator>(psOutput, pids);
335
- psOutput.resize(0);
336
+ ProcessMetricMap result = parsePsOutput<Collection, ConstIterator>(
337
+ psOutput.data, pids);
338
+ psOutput.data.resize(0);
336
339
  if (canMeasureRealMemory) {
337
340
  ProcessMetricMap::iterator it;
338
341
  for (it = result.begin(); it != result.end(); it++) {
@@ -0,0 +1,85 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2018 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
+
27
+ #include <new>
28
+ #include <exception>
29
+
30
+ #include <WrapperRegistry/CBindings.h>
31
+ #include <WrapperRegistry/Entry.h>
32
+ #include <WrapperRegistry/Registry.h>
33
+
34
+ using namespace Passenger;
35
+ using namespace Passenger::WrapperRegistry;
36
+
37
+
38
+ int
39
+ psg_wrapper_registry_entry_is_null(const PsgWrapperRegistryEntry *entry) {
40
+ const Entry *cxxEntry = static_cast<const Entry *>(entry);
41
+ return (int) cxxEntry->isNull();
42
+ }
43
+
44
+ const char *
45
+ psg_wrapper_registry_entry_get_language(const PsgWrapperRegistryEntry *entry, size_t *len) {
46
+ const Entry *cxxEntry = static_cast<const Entry *>(entry);
47
+ if (len != NULL) {
48
+ *len = cxxEntry->language.size();
49
+ }
50
+ return cxxEntry->language.data();
51
+ }
52
+
53
+
54
+ PsgWrapperRegistry *
55
+ psg_wrapper_registry_new() {
56
+ try {
57
+ return static_cast<PsgWrapperRegistry *>(new Registry());
58
+ } catch (const std::bad_alloc &) {
59
+ return NULL;
60
+ }
61
+ }
62
+
63
+ void
64
+ psg_wrapper_registry_free(PsgWrapperRegistry *registry) {
65
+ Registry *cxxRegistry = static_cast<Registry *>(registry);
66
+ delete cxxRegistry;
67
+ }
68
+
69
+ void
70
+ psg_wrapper_registry_finalize(PsgWrapperRegistry *registry) {
71
+ Registry *cxxRegistry = static_cast<Registry *>(registry);
72
+ cxxRegistry->finalize();
73
+ }
74
+
75
+ const PsgWrapperRegistryEntry *
76
+ psg_wrapper_registry_lookup(PsgWrapperRegistry *registry,
77
+ const char *name, size_t size)
78
+ {
79
+ const Registry *cxxRegistry = static_cast<const Registry *>(registry);
80
+ if (size == (size_t) -1) {
81
+ size = strlen(name);
82
+ }
83
+ return static_cast<const PsgWrapperRegistryEntry *>(
84
+ &cxxRegistry->lookup(StaticString(name, size)));
85
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2018 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_WRAPPER_REGISTRY_CBINDINGS_H_
27
+ #define _PASSENGER_WRAPPER_REGISTRY_CBINDINGS_H_
28
+
29
+ #include <stddef.h>
30
+
31
+ #ifdef __cplusplus
32
+ extern "C" {
33
+ #endif
34
+
35
+
36
+ typedef void PsgWrapperRegistryEntry;
37
+
38
+ int psg_wrapper_registry_entry_is_null(const PsgWrapperRegistryEntry *entry);
39
+ const char *psg_wrapper_registry_entry_get_language(const PsgWrapperRegistryEntry *entry, size_t *len);
40
+
41
+
42
+ typedef void PsgWrapperRegistry;
43
+
44
+ PsgWrapperRegistry *psg_wrapper_registry_new();
45
+ void psg_wrapper_registry_free(PsgWrapperRegistry *registry);
46
+
47
+ void psg_wrapper_registry_finalize(PsgWrapperRegistry *registry);
48
+ const PsgWrapperRegistryEntry *psg_wrapper_registry_lookup(PsgWrapperRegistry *registry,
49
+ const char *name, size_t size);
50
+
51
+
52
+ #ifdef __cplusplus
53
+ } // extern "C"
54
+ #endif
55
+
56
+ #endif /* _PASSENGER_WRAPPER_REGISTRY_CBINDINGS_H_ */
@@ -0,0 +1,112 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2018 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_WRAPPER_REGISTRY_WRAPPER_H_
27
+ #define _PASSENGER_WRAPPER_REGISTRY_WRAPPER_H_
28
+
29
+ #include <boost/container/small_vector.hpp>
30
+ #include <StaticString.h>
31
+
32
+ namespace Passenger {
33
+ namespace WrapperRegistry {
34
+
35
+ using namespace std;
36
+
37
+
38
+ struct Entry {
39
+ /**
40
+ * A identifier-like name for this language. All-lowercase, no spaces.
41
+ * Related to passenger_app_type.
42
+ * Example: "ruby"
43
+ */
44
+ StaticString language;
45
+
46
+ /**
47
+ * A human-readable name for this language.
48
+ * Example: "Ruby"
49
+ */
50
+ StaticString languageDisplayName;
51
+
52
+ /**
53
+ * Path to the wrapper to use. If `suppliedByThirdParty` is false, then
54
+ * the path is considered relative to helperScriptsDir.
55
+ */
56
+ StaticString path;
57
+
58
+ /**
59
+ * The title that spawned processes for this language should assume.
60
+ * Example: "Passenger RubyApp"
61
+ */
62
+ StaticString processTitle;
63
+
64
+ /**
65
+ * A default command for the interpreter of this language.
66
+ * Will be looked up in $PATH.
67
+ * Example: "ruby"
68
+ */
69
+ StaticString defaultInterpreter;
70
+
71
+ /**
72
+ * A list of startup file names that we should look for
73
+ * in order to autodetect whether an app belongs to this
74
+ * language. Any of these files are also considered to be
75
+ * the entrypoint to the app.
76
+ * Example: "config.ru", "index.js", "app.js"
77
+ */
78
+ boost::container::small_vector<StaticString, 2> defaultStartupFiles;
79
+
80
+ bool suppliedByThirdParty;
81
+
82
+ Entry()
83
+ : suppliedByThirdParty(false)
84
+ { }
85
+
86
+ // In C++98, `boost::container::small_vector` causes our default
87
+ // assignment operator to become `operator=(Entry &)`, which is
88
+ // incompatible with the Registry's usage of StringKeyTable.
89
+ // We fix this by writing out own assignment operator.
90
+ Entry &operator=(const Entry &other) {
91
+ if (this != &other) {
92
+ language = other.language;
93
+ languageDisplayName = other.languageDisplayName;
94
+ path = other.path;
95
+ processTitle = other.processTitle;
96
+ defaultInterpreter = other.defaultInterpreter;
97
+ defaultStartupFiles = other.defaultStartupFiles;
98
+ suppliedByThirdParty = other.suppliedByThirdParty;
99
+ }
100
+ return *this;
101
+ }
102
+
103
+ bool isNull() const {
104
+ return language.empty();
105
+ }
106
+ };
107
+
108
+
109
+ } // namespace WrapperRegistry
110
+ } // namespace Passenger
111
+
112
+ #endif /* _PASSENGER_WRAPPER_REGISTRY_WRAPPER_H_ */