0
#include <sys/resource.h>
0
@@ -63,6 +62,9 @@ typedef shared_ptr<Client> ClientPtr;
0
#define SERVER_SOCKET_FD 3
0
+ * Whether we received a signal indicating that we shut gracefully shutdown.
0
static bool serverDone = false;
0
@@ -80,8 +82,8 @@ private:
0
string statusReportFIFO;
0
- void statusReportThread() {
0
+ void statusReportThreadMain() {
0
@@ -89,18 +91,20 @@ private:
0
ret = stat(statusReportFIFO.c_str(), &buf);
0
} while (ret == -1 && errno == EINTR);
0
if (ret == -1 || !S_ISFIFO(buf.st_mode)) {
0
- // Something bad happened with the status
0
- // report FIFO, so we bail out.
0
+ // Something bad happened with the status report
0
+ // FIFO, so we bail out.
0
- f = fopen(statusReportFIFO.c_str(), "w");
0
- } while (f == NULL && errno == EINTR);
0
+ f = fopen(statusReportFIFO.c_str(), "w");
0
+ } while (f == NULL && errno == EINTR && !serverDone);
0
+ if (f == NULL || serverDone) {
0
string report(pool.toString());
0
@@ -117,23 +121,12 @@ public:
0
const string &spawnServerCommand,
0
const string &rubyCommand,
0
+ const string &statusReportFIFO)
0
: pool(spawnServerCommand, logFile, rubyCommand, user) {
0
this->serverSocket = serverSocket;
0
- char filename[PATH_MAX];
0
- snprintf(filename, sizeof(filename), "/tmp/passenger_status.%d.fifo",
0
- filename[PATH_MAX - 1] = '\0';
0
- if (mkfifo(filename, S_IRUSR | S_IWUSR) == -1 && errno != EEXIST) {
0
- fprintf(stderr, "*** WARNING: Could not create FIFO '%s'; "
0
- "disabling Passenger ApplicationPool status reporting.\n",
0
- statusReportFIFO = filename;
0
+ this->statusReportFIFO = statusReportFIFO;
0
@@ -290,8 +283,10 @@ private:
0
} catch (const SystemException &e) {
0
- P_WARN("Exception in ApplicationPoolServer client thread during "
0
- "reading of a message: " << e.what());
0
+ P_WARN("Exception in ApplicationPoolServer client thread during "
0
+ "reading of a message: " << e.what());
0
@@ -368,7 +363,11 @@ public:
0
+ // We don't want to wait for the client to close the connection,
0
+ // if we were told to shutdown.
0
@@ -383,14 +382,14 @@ gracefulShutdown(int sig) {
0
if (!statusReportFIFO.empty()) {
0
- bind(&Server::statusReportThread, this),
0
+ bind(&Server::statusReportThreadMain, this),
0
signal(SIGINT, gracefulShutdown);
0
siginterrupt(SIGINT, 1);
0
@@ -441,7 +440,7 @@ Server::start() {
0
main(int argc, char *argv[]) {
0
- Server server(SERVER_SOCKET_FD, argv[1], argv[2], argv[3], argv[4]
);
0
+ Server server(SERVER_SOCKET_FD, argv[1], argv[2], argv[3], argv[4]
, argv[5]);
0
} catch (const exception &e) {
0
fprintf(stderr, "*** An unexpected error occured in the Passenger "
Comments
No one has commented yet.