0
@@ -221,37 +221,71 @@ private:
0
+ * The PID of the ApplicationPool server process. If no server process
0
+ * is running, then <tt>serverPid == 0</tt>.
0
+ * The connection to the ApplicationPool server process. If no server
0
+ * process is running, then <tt>serverSocket == -1</tt>.
0
+ * Shutdown the currently running ApplicationPool server process.
0
+ * @pre serverSocket != -1 && serverPid != 0
0
+ * @post serverSocket == -1 && serverPid == 0
0
+ void shutdownServer() {
0
+ ret = close(serverSocket);
0
+ } while (ret == -1 && errno == EINTR);
0
+ P_DEBUG("Waiting for existing ApplicationPoolServerExecutable to exit...");
0
+ while (!done && time(NULL) < begin + 5) {
0
+ done = waitpid(serverPid, NULL, WNOHANG) > 0;
0
+ P_DEBUG("ApplicationPoolServerExecutable exited.");
0
+ P_DEBUG("ApplicationPoolServerExecutable not exited in time. Killing it...");
0
+ kill(serverPid, SIGTERM);
0
+ waitpid(serverPid, NULL, 0);
0
+ * Start an ApplicationPool server process. If there's already one running,
0
+ * then the currently running one will be shutdown.
0
+ * @post serverSocket != -1 && serverPid != 0
0
+ * @throw SystemException Something went wrong.
0
- // Shutdown existing server instance.
0
- ret = close(serverSocket);
0
- } while (ret == -1 && errno == EINTR);
0
- P_DEBUG("Waiting for existing ApplicationPoolServerExecutable to exit...");
0
- while (!done && time(NULL) < begin + 5) {
0
- done = waitpid(serverPid, NULL, WNOHANG) > 0;
0
- P_DEBUG("ApplicationPoolServerExecutable exited.");
0
- P_DEBUG("ApplicationPoolServerExecutable not exited in time. Killing it...");
0
- kill(serverPid, SIGTERM);
0
- waitpid(serverPid, NULL, 0);
0
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
0
@@ -342,9 +376,7 @@ public:
0
~ApplicationPoolServer() {
0
if (serverSocket != -1) {
0
- // TODO: don't wait indefinitely
0
- waitpid(serverPid, NULL, 0);
0
@@ -388,15 +420,18 @@ public:
0
- * Detach the server by freeing up some server resources such as file descriptors.
0
- * This should be called by child processes that wish to use a server, but do
0
- * not run the server itself.
0
+ * Detach the server, thereby telling it that we don't want to connect
0
+ * to it anymore. This frees up some resources in the current process,
0
+ * such as file descriptors.
0
- * This method may only be called once. The ApplicationPoolServer object
0
- * will become unusable once detach() has been called.
0
+ * This method is particularily useful to Apache worker processes that
0
+ * have just established a connection with the ApplicationPool server.
0
+ * Any sessions that are opened prior to calling detach(), will keep
0
+ * working even after a detach().
0
- * @warning Never call this method in the process in which this
0
- * ApplicationPoolServer was created!
0
+ * This method may only be called once. The ApplicationPoolServer object
0
+ * will become unusable once detach() has been called, so call connect()
0
+ * before calling detach().
Comments
No one has commented yet.