passenger 5.0.9 → 5.0.10

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 (106) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +15 -0
  5. data/CONTRIBUTORS +6 -0
  6. data/README.md +1 -1
  7. data/bin/passenger-install-apache2-module +24 -11
  8. data/bin/passenger-status +29 -14
  9. data/build/agents.rb +12 -10
  10. data/build/cxx_tests.rb +30 -30
  11. data/doc/Design and Architecture.html +1 -10
  12. data/doc/Design and Architecture.txt +1 -6
  13. data/doc/Users guide Apache.html +1 -19
  14. data/doc/Users guide Apache.txt +1 -1
  15. data/doc/Users guide Nginx.html +2 -20
  16. data/doc/Users guide Nginx.txt +2 -2
  17. data/doc/users_guide_snippets/tips.txt +0 -9
  18. data/ext/common/ApplicationPool2/ApiKey.h +158 -0
  19. data/ext/common/ApplicationPool2/BasicGroupInfo.h +81 -0
  20. data/ext/common/ApplicationPool2/BasicProcessInfo.h +106 -0
  21. data/ext/common/ApplicationPool2/Common.h +5 -44
  22. data/ext/common/ApplicationPool2/Context.h +94 -0
  23. data/ext/common/ApplicationPool2/Group.h +130 -1205
  24. data/ext/common/ApplicationPool2/Group/InitializationAndShutdown.cpp +190 -0
  25. data/ext/common/ApplicationPool2/Group/InternalUtils.cpp +329 -0
  26. data/ext/common/ApplicationPool2/Group/LifetimeAndBasics.cpp +103 -0
  27. data/ext/common/ApplicationPool2/{Pool/Debug.h → Group/Miscellaneous.cpp} +40 -38
  28. data/ext/common/ApplicationPool2/Group/OutOfBandWork.cpp +323 -0
  29. data/ext/common/ApplicationPool2/Group/ProcessListManagement.cpp +606 -0
  30. data/ext/common/ApplicationPool2/Group/SessionManagement.cpp +337 -0
  31. data/ext/common/ApplicationPool2/Group/SpawningAndRestarting.cpp +478 -0
  32. data/ext/common/ApplicationPool2/Group/StateInspection.cpp +197 -0
  33. data/ext/common/ApplicationPool2/Group/Verification.cpp +159 -0
  34. data/ext/common/ApplicationPool2/Implementation.cpp +19 -1401
  35. data/ext/common/ApplicationPool2/Options.h +5 -5
  36. data/ext/common/ApplicationPool2/Pool.h +260 -815
  37. data/ext/common/ApplicationPool2/Pool/{AnalyticsCollection.h → AnalyticsCollection.cpp} +55 -56
  38. data/ext/common/ApplicationPool2/Pool/{GarbageCollection.h → GarbageCollection.cpp} +49 -49
  39. data/ext/common/ApplicationPool2/Pool/GeneralUtils.cpp +241 -0
  40. data/ext/common/ApplicationPool2/Pool/GroupUtils.cpp +276 -0
  41. data/ext/common/ApplicationPool2/Pool/InitializationAndShutdown.cpp +145 -0
  42. data/ext/common/ApplicationPool2/Pool/Miscellaneous.cpp +244 -0
  43. data/ext/common/ApplicationPool2/Pool/ProcessUtils.cpp +330 -0
  44. data/ext/common/ApplicationPool2/Pool/StateInspection.cpp +299 -0
  45. data/ext/common/ApplicationPool2/Process.h +399 -205
  46. data/ext/common/ApplicationPool2/Session.h +70 -28
  47. data/ext/common/ApplicationPool2/Socket.h +1 -0
  48. data/ext/common/Constants.h +11 -3
  49. data/ext/common/Exceptions.h +1 -1
  50. data/ext/common/Logging.cpp +9 -4
  51. data/ext/common/Logging.h +6 -0
  52. data/ext/common/ServerKit/HttpServer.h +225 -215
  53. data/ext/common/ServerKit/Server.h +57 -57
  54. data/ext/common/SpawningKit/BackgroundIOCapturer.h +160 -0
  55. data/ext/common/SpawningKit/Config.h +107 -0
  56. data/ext/common/{ApplicationPool2 → SpawningKit}/DirectSpawner.h +17 -16
  57. data/ext/common/{ApplicationPool2 → SpawningKit}/DummySpawner.h +33 -33
  58. data/ext/common/{ApplicationPool2/SpawnerFactory.h → SpawningKit/Factory.h} +17 -17
  59. data/ext/common/{ApplicationPool2/ComponentInfo.h → SpawningKit/Options.h} +8 -21
  60. data/ext/common/SpawningKit/PipeWatcher.h +148 -0
  61. data/ext/common/{ApplicationPool2/PipeWatcher.h → SpawningKit/Result.h} +15 -33
  62. data/ext/common/{ApplicationPool2 → SpawningKit}/SmartSpawner.h +52 -57
  63. data/ext/common/{ApplicationPool2 → SpawningKit}/Spawner.h +83 -371
  64. data/ext/common/SpawningKit/UserSwitchingRules.h +265 -0
  65. data/ext/common/Utils/BufferedIO.h +24 -0
  66. data/ext/common/{ApplicationPool2/SpawnObject.h → Utils/ClassUtils.h} +24 -51
  67. data/ext/common/Utils/IOUtils.cpp +70 -0
  68. data/ext/common/Utils/IOUtils.h +19 -0
  69. data/ext/common/Utils/JsonUtils.h +113 -0
  70. data/ext/common/Utils/StrIntUtils.h +29 -0
  71. data/ext/common/Utils/json.h +1 -1
  72. data/ext/common/agents/ApiServerUtils.h +941 -0
  73. data/ext/common/agents/HelperAgent/{AdminServer.h → ApiServer.h} +163 -365
  74. data/ext/common/agents/HelperAgent/Main.cpp +86 -88
  75. data/ext/common/agents/HelperAgent/OptionParser.h +9 -10
  76. data/ext/common/agents/HelperAgent/RequestHandler/BufferBody.cpp +3 -0
  77. data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +2 -0
  78. data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +1 -1
  79. data/ext/common/agents/HelperAgent/RequestHandler/SendRequest.cpp +2 -2
  80. data/ext/common/agents/LoggingAgent/ApiServer.h +279 -0
  81. data/ext/common/agents/LoggingAgent/Main.cpp +41 -51
  82. data/ext/common/agents/LoggingAgent/OptionParser.h +11 -11
  83. data/ext/common/agents/Watchdog/ApiServer.h +311 -0
  84. data/ext/common/agents/Watchdog/Main.cpp +91 -65
  85. data/helper-scripts/prespawn +2 -0
  86. data/lib/phusion_passenger.rb +1 -1
  87. data/lib/phusion_passenger/admin_tools/instance.rb +1 -1
  88. data/lib/phusion_passenger/common_library.rb +27 -14
  89. data/lib/phusion_passenger/config/{admin_command_command.rb → api_call_command.rb} +19 -16
  90. data/lib/phusion_passenger/config/detach_process_command.rb +6 -3
  91. data/lib/phusion_passenger/config/main.rb +3 -5
  92. data/lib/phusion_passenger/config/reopen_logs_command.rb +29 -7
  93. data/lib/phusion_passenger/config/restart_app_command.rb +13 -4
  94. data/lib/phusion_passenger/config/utils.rb +15 -8
  95. data/lib/phusion_passenger/constants.rb +6 -2
  96. data/lib/phusion_passenger/platform_info/apache.rb +4 -0
  97. data/lib/phusion_passenger/platform_info/apache_detector.rb +18 -3
  98. data/resources/templates/apache2/mpm_unknown.txt.erb +20 -0
  99. metadata +42 -21
  100. metadata.gz.asc +7 -7
  101. data/ext/common/ApplicationPool2/Pool/GeneralUtils.h +0 -127
  102. data/ext/common/ApplicationPool2/Pool/Inspection.h +0 -219
  103. data/ext/common/ApplicationPool2/Pool/ProcessUtils.h +0 -85
  104. data/ext/common/ApplicationPool2/SuperGroup.h +0 -706
  105. data/ext/common/agents/LoggingAgent/AdminServer.h +0 -435
  106. data/ext/common/agents/Watchdog/AdminServer.h +0 -432
@@ -491,63 +491,6 @@ private:
491
491
  }
492
492
 
493
493
  protected:
494
- /***** Protected API *****/
495
-
496
- /** Get a thread-safe reference to the client. As long as the client
497
- * has a reference, it will never be added to the freelist.
498
- */
499
- ClientRefType getClientRef(Client *client, const char *file, unsigned int line) {
500
- return ClientRefType(client, file, line);
501
- }
502
-
503
- /**
504
- * Returns a pointer to the BaseServer that created the given Client object.
505
- * Unlike the void pointer that Client::getServerBaseClassPointer() returns,
506
- * this method's typed return value allows safe recasting of the result pointer.
507
- */
508
- static const BaseServer *getConstServerFromClient(const Client *client) {
509
- return static_cast<BaseServer *>(client->getServerBaseClassPointer());
510
- }
511
-
512
- static BaseServer *getServerFromClient(Client *client) {
513
- return static_cast<BaseServer *>(client->getServerBaseClassPointer());
514
- }
515
-
516
- /** Increase client reference count. */
517
- void refClient(Client *client, const char *file, unsigned int line) {
518
- int oldRefcount = client->refcount.fetch_add(1, boost::memory_order_relaxed);
519
- SKC_TRACE_WITH_POS(client, 3, file, line,
520
- "Refcount increased; it is now " << (oldRefcount + 1));
521
- }
522
-
523
- /** Decrease client reference count. Adds client to the
524
- * freelist if reference count drops to 0.
525
- */
526
- void unrefClient(Client *client, const char *file, unsigned int line) {
527
- int oldRefcount = client->refcount.fetch_sub(1, boost::memory_order_release);
528
- assert(oldRefcount >= 1);
529
-
530
- SKC_TRACE_WITH_POS(client, 3, file, line,
531
- "Refcount decreased; it is now " << (oldRefcount - 1));
532
- if (oldRefcount == 1) {
533
- boost::atomic_thread_fence(boost::memory_order_acquire);
534
-
535
- if (ctx->libev->onEventLoopThread()) {
536
- assert(client->getConnState() != Client::IN_FREELIST);
537
- /* As long as the client is still in the ACTIVE state, it has at least
538
- * one reference, namely from the Server itself. Therefore it's impossible
539
- * to get to a zero reference count without having disconnected a client. */
540
- P_ASSERT_EQ(client->getConnState(), Client::DISCONNECTED);
541
- clientReachedZeroRefcount(client);
542
- } else {
543
- // Let the event loop handle the client reaching the 0 refcount.
544
- SKC_TRACE(client, 3, "Passing client object to event loop thread");
545
- passClientToEventLoopThread(client);
546
- }
547
- }
548
- }
549
-
550
-
551
494
  /***** Hooks *****/
552
495
 
553
496
  virtual void onClientObjectCreated(Client *client) {
@@ -864,6 +807,40 @@ public:
864
807
  return NULL;
865
808
  }
866
809
 
810
+ /** Increase client reference count. */
811
+ void refClient(Client *client, const char *file, unsigned int line) {
812
+ int oldRefcount = client->refcount.fetch_add(1, boost::memory_order_relaxed);
813
+ SKC_TRACE_WITH_POS(client, 3, file, line,
814
+ "Refcount increased; it is now " << (oldRefcount + 1));
815
+ }
816
+
817
+ /** Decrease client reference count. Adds client to the
818
+ * freelist if reference count drops to 0.
819
+ */
820
+ void unrefClient(Client *client, const char *file, unsigned int line) {
821
+ int oldRefcount = client->refcount.fetch_sub(1, boost::memory_order_release);
822
+ assert(oldRefcount >= 1);
823
+
824
+ SKC_TRACE_WITH_POS(client, 3, file, line,
825
+ "Refcount decreased; it is now " << (oldRefcount - 1));
826
+ if (oldRefcount == 1) {
827
+ boost::atomic_thread_fence(boost::memory_order_acquire);
828
+
829
+ if (ctx->libev->onEventLoopThread()) {
830
+ assert(client->getConnState() != Client::IN_FREELIST);
831
+ /* As long as the client is still in the ACTIVE state, it has at least
832
+ * one reference, namely from the Server itself. Therefore it's impossible
833
+ * to get to a zero reference count without having disconnected a client. */
834
+ P_ASSERT_EQ(client->getConnState(), Client::DISCONNECTED);
835
+ clientReachedZeroRefcount(client);
836
+ } else {
837
+ // Let the event loop handle the client reaching the 0 refcount.
838
+ SKC_TRACE(client, 3, "Passing client object to event loop thread");
839
+ passClientToEventLoopThread(client);
840
+ }
841
+ }
842
+ }
843
+
867
844
  bool disconnect(int fd) {
868
845
  assert(serverState != FINISHED_SHUTDOWN);
869
846
  Client *client = lookupClient(fd);
@@ -1024,6 +1001,29 @@ public:
1024
1001
  }
1025
1002
 
1026
1003
 
1004
+ /***** Miscellaneous *****/
1005
+
1006
+ /** Get a thread-safe reference to the client. As long as the client
1007
+ * has a reference, it will never be added to the freelist.
1008
+ */
1009
+ ClientRefType getClientRef(Client *client, const char *file, unsigned int line) {
1010
+ return ClientRefType(client, file, line);
1011
+ }
1012
+
1013
+ /**
1014
+ * Returns a pointer to the BaseServer that created the given Client object.
1015
+ * Unlike the void pointer that Client::getServerBaseClassPointer() returns,
1016
+ * this method's typed return value allows safe recasting of the result pointer.
1017
+ */
1018
+ static const BaseServer *getConstServerFromClient(const Client *client) {
1019
+ return static_cast<BaseServer *>(client->getServerBaseClassPointer());
1020
+ }
1021
+
1022
+ static BaseServer *getServerFromClient(Client *client) {
1023
+ return static_cast<BaseServer *>(client->getServerBaseClassPointer());
1024
+ }
1025
+
1026
+
1027
1027
  /***** Friend-public methods and hook implementations *****/
1028
1028
 
1029
1029
  void _refClient(Client *client, const char *file, unsigned int line) {
@@ -0,0 +1,160 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2011-2015 Phusion
4
+ *
5
+ * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ */
25
+ #ifndef _PASSENGER_SPAWNING_KIT_BACKGROUND_IO_CAPTURER_H_
26
+ #define _PASSENGER_SPAWNING_KIT_BACKGROUND_IO_CAPTURER_H_
27
+
28
+ #include <boost/thread.hpp>
29
+ #include <boost/bind.hpp>
30
+ #include <boost/foreach.hpp>
31
+ #include <oxt/backtrace.hpp>
32
+ #include <oxt/system_calls.hpp>
33
+ #include <string>
34
+ #include <vector>
35
+ #include <cstring>
36
+
37
+ #include <sys/types.h>
38
+
39
+ #include <Logging.h>
40
+ #include <FileDescriptor.h>
41
+ #include <StaticString.h>
42
+ #include <Utils.h>
43
+ #include <Utils/StrIntUtils.h>
44
+
45
+ namespace Passenger {
46
+ namespace SpawningKit {
47
+
48
+ using namespace std;
49
+
50
+
51
+ /**
52
+ * Given a file descriptor, captures its output in a background thread
53
+ * and also forwards it immediately to a target file descriptor.
54
+ * Call stop() to stop the background thread and to obtain the captured
55
+ * output so far.
56
+ */
57
+ class BackgroundIOCapturer {
58
+ private:
59
+ FileDescriptor fd;
60
+ pid_t pid;
61
+ const char *channelName;
62
+ boost::mutex dataSyncher;
63
+ string data;
64
+ oxt::thread *thr;
65
+
66
+ void capture() {
67
+ TRACE_POINT();
68
+ while (!this_thread::interruption_requested()) {
69
+ char buf[1024 * 8];
70
+ ssize_t ret;
71
+
72
+ UPDATE_TRACE_POINT();
73
+ ret = syscalls::read(fd, buf, sizeof(buf));
74
+ int e = errno;
75
+ this_thread::disable_syscall_interruption dsi;
76
+ if (ret == 0) {
77
+ break;
78
+ } else if (ret == -1) {
79
+ if (e != EAGAIN && e != EWOULDBLOCK) {
80
+ P_WARN("Background I/O capturer error: " <<
81
+ strerror(e) << " (errno=" << e << ")");
82
+ break;
83
+ }
84
+ } else {
85
+ {
86
+ boost::lock_guard<boost::mutex> l(dataSyncher);
87
+ data.append(buf, ret);
88
+ }
89
+ UPDATE_TRACE_POINT();
90
+ if (ret == 1 && buf[0] == '\n') {
91
+ printAppOutput(pid, channelName, "", 0);
92
+ } else {
93
+ vector<StaticString> lines;
94
+ if (ret > 0 && buf[ret - 1] == '\n') {
95
+ ret--;
96
+ }
97
+ split(StaticString(buf, ret), '\n', lines);
98
+ foreach (const StaticString line, lines) {
99
+ printAppOutput(pid, channelName, line.data(), line.size());
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ public:
107
+ BackgroundIOCapturer(const FileDescriptor &_fd, pid_t _pid, const char *_channelName)
108
+ : fd(_fd),
109
+ pid(_pid),
110
+ channelName(_channelName),
111
+ thr(NULL)
112
+ { }
113
+
114
+ ~BackgroundIOCapturer() {
115
+ TRACE_POINT();
116
+ if (thr != NULL) {
117
+ this_thread::disable_interruption di;
118
+ this_thread::disable_syscall_interruption dsi;
119
+ thr->interrupt_and_join();
120
+ delete thr;
121
+ thr = NULL;
122
+ }
123
+ }
124
+
125
+ const FileDescriptor &getFd() const {
126
+ return fd;
127
+ }
128
+
129
+ void start() {
130
+ assert(thr == NULL);
131
+ thr = new oxt::thread(boost::bind(&BackgroundIOCapturer::capture, this),
132
+ "Background I/O capturer", 64 * 1024);
133
+ }
134
+
135
+ string stop() {
136
+ TRACE_POINT();
137
+ assert(thr != NULL);
138
+ this_thread::disable_interruption di;
139
+ this_thread::disable_syscall_interruption dsi;
140
+ thr->interrupt_and_join();
141
+ delete thr;
142
+ thr = NULL;
143
+ boost::lock_guard<boost::mutex> l(dataSyncher);
144
+ return data;
145
+ }
146
+
147
+ void appendToBuffer(const StaticString &dataToAdd) {
148
+ TRACE_POINT();
149
+ boost::lock_guard<boost::mutex> l(dataSyncher);
150
+ data.append(dataToAdd.data(), dataToAdd.size());
151
+ }
152
+ };
153
+
154
+ typedef boost::shared_ptr<BackgroundIOCapturer> BackgroundIOCapturerPtr;
155
+
156
+
157
+ } // namespace SpawningKit
158
+ } // namespace Passenger
159
+
160
+ #endif /* _PASSENGER_SPAWNING_KIT_BACKGROUND_IO_CAPTURER_H_ */
@@ -0,0 +1,107 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2011-2015 Phusion
4
+ *
5
+ * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ */
25
+ #ifndef _PASSENGER_SPAWNING_KIT_CONFIG_H_
26
+ #define _PASSENGER_SPAWNING_KIT_CONFIG_H_
27
+
28
+ #include <boost/function.hpp>
29
+ #include <boost/make_shared.hpp>
30
+ #include <string>
31
+ #include <cstddef>
32
+
33
+ #include <ResourceLocator.h>
34
+ #include <RandomGenerator.h>
35
+ #include <Exceptions.h>
36
+ #include <UnionStation/Core.h>
37
+ #include <Utils/VariantMap.h>
38
+
39
+ namespace Passenger {
40
+ namespace ApplicationPool2 {
41
+ class Options;
42
+ } // namespace ApplicationPool2
43
+ } // namespace Passenger
44
+
45
+ namespace Passenger {
46
+ namespace SpawningKit {
47
+
48
+ using namespace std;
49
+
50
+
51
+ struct Config;
52
+ typedef ApplicationPool2::Options Options;
53
+ typedef boost::shared_ptr<Config> ConfigPtr;
54
+
55
+ typedef void (*ErrorHandler)(const ConfigPtr &config, SpawnException &e, const Options &options);
56
+ typedef boost::function<void (const char *data, unsigned int size)> OutputHandler;
57
+
58
+ struct Config {
59
+ // Used by error pages and hooks.
60
+ ResourceLocator *resourceLocator;
61
+ const VariantMap *agentsOptions;
62
+ ErrorHandler errorHandler;
63
+
64
+ // Used for Union Station logging.
65
+ UnionStation::CorePtr unionStationCore;
66
+
67
+ // Used by SmartSpawner and DirectSpawner.
68
+ RandomGeneratorPtr randomGenerator;
69
+ string instanceDir;
70
+
71
+ // Used by DummySpawner and SpawnerFactory.
72
+ unsigned int concurrency;
73
+ unsigned int spawnerCreationSleepTime;
74
+ unsigned int spawnTime;
75
+
76
+ // Used by PipeWatcher.
77
+ OutputHandler outputHandler;
78
+
79
+ // Other.
80
+ void *data;
81
+
82
+ Config()
83
+ : resourceLocator(NULL),
84
+ agentsOptions(NULL),
85
+ errorHandler(NULL),
86
+ concurrency(1),
87
+ spawnerCreationSleepTime(0),
88
+ spawnTime(0),
89
+ data(NULL)
90
+ { }
91
+
92
+ void finalize() {
93
+ TRACE_POINT();
94
+ if (resourceLocator == NULL) {
95
+ throw RuntimeException("ResourceLocator not initialized");
96
+ }
97
+ if (randomGenerator == NULL) {
98
+ randomGenerator = boost::make_shared<RandomGenerator>();
99
+ }
100
+ }
101
+ };
102
+
103
+
104
+ } // namespace ApplicationPool2
105
+ } // namespace Passenger
106
+
107
+ #endif /* _PASSENGER_SPAWNING_KIT_CONFIG_H_ */
@@ -22,17 +22,17 @@
22
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  * THE SOFTWARE.
24
24
  */
25
- #ifndef _PASSENGER_APPLICATION_POOL2_DIRECT_SPAWNER_H_
26
- #define _PASSENGER_APPLICATION_POOL2_DIRECT_SPAWNER_H_
25
+ #ifndef _PASSENGER_SPAWNING_KIT_DIRECT_SPAWNER_H_
26
+ #define _PASSENGER_SPAWNING_KIT_DIRECT_SPAWNER_H_
27
27
 
28
- #include <ApplicationPool2/Spawner.h>
28
+ #include <SpawningKit/Spawner.h>
29
29
  #include <Constants.h>
30
30
  #include <limits.h> // for PTHREAD_STACK_MIN
31
31
  #include <pthread.h>
32
32
 
33
33
 
34
34
  namespace Passenger {
35
- namespace ApplicationPool2 {
35
+ namespace SpawningKit {
36
36
 
37
37
  using namespace std;
38
38
  using namespace boost;
@@ -121,8 +121,8 @@ private:
121
121
  }
122
122
 
123
123
  if (shouldLoadShellEnvvars(options, preparation)) {
124
- command.push_back(preparation.shell);
125
- command.push_back(preparation.shell);
124
+ command.push_back(preparation.userSwitching.shell);
125
+ command.push_back(preparation.userSwitching.shell);
126
126
  command.push_back("-lc");
127
127
  command.push_back("exec \"$@\"");
128
128
  command.push_back("SpawnPreparerShell");
@@ -146,11 +146,11 @@ private:
146
146
  }
147
147
 
148
148
  public:
149
- DirectSpawner(const SpawnerConfigPtr &_config)
149
+ DirectSpawner(const ConfigPtr &_config)
150
150
  : Spawner(_config)
151
151
  { }
152
152
 
153
- virtual SpawnObject spawn(const Options &options) {
153
+ virtual Result spawn(const Options &options) {
154
154
  TRACE_POINT();
155
155
  this_thread::disable_interruption di;
156
156
  this_thread::disable_syscall_interruption dsi;
@@ -162,7 +162,8 @@ public:
162
162
  vector<string> command = createCommand(options, preparation, args);
163
163
  SocketPair adminSocket = createUnixSocketPair(__FILE__, __LINE__);
164
164
  Pipe errorPipe = createPipe(__FILE__, __LINE__);
165
- DebugDirPtr debugDir = boost::make_shared<DebugDir>(preparation.uid, preparation.gid);
165
+ DebugDirPtr debugDir = boost::make_shared<DebugDir>(preparation.userSwitching.uid,
166
+ preparation.userSwitching.gid);
166
167
  pid_t pid;
167
168
 
168
169
  pid = syscalls::fork();
@@ -231,23 +232,23 @@ public:
231
232
  details.options = &options;
232
233
  details.debugDir = debugDir;
233
234
 
234
- SpawnObject object;
235
+ Result result;
235
236
  {
236
237
  this_thread::restore_interruption ri(di);
237
238
  this_thread::restore_syscall_interruption rsi(dsi);
238
- object = negotiateSpawn(details);
239
+ result = negotiateSpawn(details);
239
240
  }
240
- detachProcess(object.process->pid);
241
+ detachProcess(result["pid"].asInt());
241
242
  guard.clear();
242
243
  P_DEBUG("Process spawning done: appRoot=" << options.appRoot <<
243
- ", pid=" << object.process->pid);
244
- return boost::move(object);
244
+ ", pid=" << result["pid"].asInt());
245
+ return result;
245
246
  }
246
247
  }
247
248
  };
248
249
 
249
250
 
250
- } // namespace ApplicationPool2
251
+ } // namespace SpawningKit
251
252
  } // namespace Passenger
252
253
 
253
- #endif /* _PASSENGER_APPLICATION_POOL2_DIRECT_SPAWNER_H_ */
254
+ #endif /* _PASSENGER_SPAWNING_KIT_DIRECT_SPAWNER_H_ */