Project

General

Profile

Bug #3222 » respawn.patch

Proper worker process respawn patch - Alan Finley, 06/30/2014 10:54 AM

View differences:

src/fcgi/Server.C 2014-06-30 10:22:21.522163217 +0400
Server::Server(WServer& wt, int argc, char *argv[])
: wt_(wt),
argc_(argc),
argv_(argv)
argv_(argv),
respawnCounter_(0)
{
instance = this;
......
* TODO: cleanup all sessions that pointed to this pid
*/
static int childrenDied = 0;
++childrenDied;
if (childrenDied < 5)
spawnSharedProcess();
else
LOG_ERROR_S(&wt_, "sessions process restart limit (5) reached");
respawnCounter_++;
break;
}
......
} else
LOG_INFO_S(&wt_, "reading FastCGI stream from stdin");
respawnMonitor_ = boost::thread(boost::bind(&Server::monitorRespawn, this));
wt_.ioService().start();
for (;;) {
......
return 0;
}
void Server::monitorRespawn()
{
for (;;)
{
if (respawnCounter_ > 0)
{
LOG_INFO_S(&wt_, "respawn monitor: launching new session process...");
spawnSharedProcess();
respawnCounter_--;
}
}
}
void Server::handleRequestThreaded(int serverSocket)
{
#ifdef WT_THREADED
-- src/fcgi/Server.h 2014-06-30 10:23:01.386287652 +0400
++ src/fcgi/Server.h 2014-06-30 10:21:26.643287702 +0400
......
* For SharedProcess session policy
*/
std::vector<int> sessionProcessPids_;
volatile int respawnCounter_;
boost::thread respawnMonitor_;
void monitorRespawn();
const std::string socketPath(const std::string& sessionId);
};
(1-1/3)