本文整理汇总了C++中PoolPtr类的典型用法代码示例。如果您正苦于以下问题:C++ PoolPtr类的具体用法?C++ PoolPtr怎么用?C++ PoolPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PoolPtr类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TRACE_POINT
void
Group::onSessionInitiateFailure(const ProcessPtr &process, Session *session) {
vector<Callback> actions;
TRACE_POINT();
// Standard resource management boilerplate stuff...
PoolPtr pool = getPool();
boost::unique_lock<boost::mutex> lock(pool->syncher);
assert(process->isAlive());
assert(isAlive() || getLifeStatus() == SHUTTING_DOWN);
UPDATE_TRACE_POINT();
P_DEBUG("Could not initiate a session with process " <<
process->inspect() << ", detaching from pool if possible");
if (!pool->detachProcessUnlocked(process, actions)) {
P_DEBUG("Process was already detached");
}
pool->fullVerifyInvariants();
lock.unlock();
runAllActions(actions);
}
示例2: getPool
void
SuperGroup::realDoInitialize(const Options &options, unsigned int generation) {
vector<ComponentInfo> componentInfos;
vector<ComponentInfo>::const_iterator it;
ExceptionPtr exception;
PoolPtr pool = getPool();
P_TRACE(2, "Initializing SuperGroup " << inspect() << " in the background...");
try {
componentInfos = loadComponentInfos(options);
} catch (const tracable_exception &e) {
exception = copyException(e);
}
if (componentInfos.empty() && exception == NULL) {
string message = "The directory " +
options.appRoot +
" does not seem to contain a web application.";
boost::shared_ptr<SpawnException> spawnException =
boost::make_shared<SpawnException>(
message, message, false);
exception = spawnException;
processAndLogNewSpawnException(*spawnException, options,
pool->getResourceLocator(), *pool->randomGenerator);
}
Pool::DebugSupportPtr debug = pool->debugSupport;
vector<Callback> actions;
{
if (debug != NULL && debug->superGroup) {
debug->debugger->send("About to finish SuperGroup initialization");
debug->messages->recv("Proceed with initializing SuperGroup");
}
boost::unique_lock<boost::mutex> lock(getPoolSyncher(pool));
this_thread::disable_interruption di;
this_thread::disable_syscall_interruption dsi;
NOT_EXPECTING_EXCEPTIONS();
if (OXT_UNLIKELY(getPool() == NULL || generation != this->generation)) {
return;
}
P_TRACE(2, "Initialization of SuperGroup " << inspect() << " almost done; grabbed lock");
assert(state == INITIALIZING);
verifyInvariants();
if (componentInfos.empty()) {
/* Somehow initialization failed. Maybe something has deleted
* the supergroup files while we're working.
*/
assert(exception != NULL);
setState(DESTROYED);
actions.reserve(getWaitlist.size());
while (!getWaitlist.empty()) {
const GetWaiter &waiter = getWaitlist.front();
actions.push_back(boost::bind(waiter.callback,
SessionPtr(), exception));
getWaitlist.pop_front();
}
} else {
for (it = componentInfos.begin(); it != componentInfos.end(); it++) {
const ComponentInfo &info = *it;
GroupPtr group = boost::make_shared<Group>(shared_from_this(),
options, info);
groups.push_back(group);
if (info.isDefault) {
defaultGroup = group.get();
}
}
setState(READY);
assignGetWaitlistToGroups(actions);
}
verifyInvariants();
P_TRACE(2, "Done initializing SuperGroup " << inspect());
}
this_thread::disable_interruption di;
this_thread::disable_syscall_interruption dsi;
runAllActions(actions);
runInitializationHooks();
}
示例3:
~Server() {
TRACE_POINT();
this_thread::disable_syscall_interruption dsi;
this_thread::disable_interruption di;
P_DEBUG("Shutting down helper agent...");
prestarterThread->interrupt_and_join();
if (messageServerThread != NULL) {
messageServerThread->interrupt_and_join();
}
messageServer.reset();
P_DEBUG("Destroying application pool...");
pool->destroy();
uninstallDiagnosticsDumper();
pool.reset();
poolLoop.stop();
requestLoop.stop();
requestHandler.reset();
if (!options.requestSocketLink.empty()) {
syscalls::unlink(options.requestSocketLink.c_str());
}
P_TRACE(2, "All threads have been shut down.");
}
示例4:
static void
sigint_cb(struct ev_loop *loop, ev_signal *w, int revents) {
P_WARN("Exiting loop");
delete handler;
handler = NULL;
pool->destroy();
pool.reset();
ev_signal_stop(loop, &sigquitwatcher);
ev_signal_stop(loop, &sigintwatcher);
ev_break(loop, EVBREAK_ONE);
}
示例5: onSigquit
void onSigquit(ev::sig &signal, int revents) {
requestHandler->inspect(cerr);
cerr.flush();
cerr << "\n" << pool->inspect();
cerr.flush();
cerr << "\n" << oxt::thread::all_backtraces();
cerr.flush();
}
示例6: processToXml
void processToXml(CommonClientContext &commonContext, SpecificContext *specificContext, const vector<string> &args) {
TRACE_POINT();
commonContext.requireRights(Account::INSPECT_BASIC_INFO);
bool includeSensitiveInfo =
commonContext.account->hasRights(Account::INSPECT_SENSITIVE_INFO) &&
args[1] == "true";
writeScalarMessage(commonContext.fd, pool->toXml(includeSensitiveInfo));
}
示例7: readlink
~Server() {
TRACE_POINT();
this_thread::disable_syscall_interruption dsi;
this_thread::disable_interruption di;
P_DEBUG("Shutting down helper agent...");
prestarterThread->interrupt_and_join();
if (messageServerThread != NULL) {
messageServerThread->interrupt_and_join();
}
messageServer.reset();
P_DEBUG("Destroying application pool...");
pool->destroy();
uninstallDiagnosticsDumper();
pool.reset();
poolLoop.stop();
requestLoop.stop();
requestHandler.reset();
if (!options.requestSocketLink.empty()) {
char path[PATH_MAX + 1];
ssize_t ret;
bool shouldUnlink;
ret = readlink(options.requestSocketLink.c_str(), path, PATH_MAX);
if (ret != -1) {
path[ret] = '\0';
// Only unlink if a new Flying Passenger instance hasn't overwritten the
// symlink.
// https://code.google.com/p/phusion-passenger/issues/detail?id=939
shouldUnlink = getRequestSocketFilename() == path;
} else {
shouldUnlink = true;
}
if (shouldUnlink) {
syscalls::unlink(options.requestSocketLink.c_str());
}
}
P_TRACE(2, "All threads have been shut down.");
}
示例8: processDetachProcess
void processDetachProcess(CommonClientContext &commonContext, SpecificContext *specificContext,
const vector<string> &args)
{
TRACE_POINT();
commonContext.requireRights(Account::DETACH);
if (pool->detachProcess((pid_t) atoi(args[1]))) {
writeArrayMessage(commonContext.fd, "true", NULL);
} else {
writeArrayMessage(commonContext.fd, "false", NULL);
}
}
示例9:
~Server() {
TRACE_POINT();
this_thread::disable_syscall_interruption dsi;
this_thread::disable_interruption di;
P_DEBUG("Shutting down helper agent...");
prestarterThread->interrupt_and_join();
if (messageServerThread != NULL) {
messageServerThread->interrupt_and_join();
}
messageServer.reset();
pool->destroy();
pool.reset();
requestHandler.reset();
poolLoop.stop();
requestLoop.stop();
P_TRACE(2, "All threads have been shut down.");
}
示例10: processInspect
bool processInspect(CommonClientContext &commonContext, SpecificContext *specificContext, const vector<string> &args) {
TRACE_POINT();
commonContext.requireRights(Account::INSPECT_BASIC_INFO);
if ((args.size() - 1) % 2 != 0) {
return false;
}
VariantMap map;
vector<string>::const_iterator it = args.begin(), end = args.end();
it++;
while (it != end) {
const string &key = *it;
it++;
const string &value = *it;
map.set(key, value);
it++;
}
writeScalarMessage(commonContext.fd, pool->inspect(Pool::InspectOptions(map)));
return true;
}
示例11: RuntimeException
Server(FileDescriptor feedbackFd, const AgentOptions &_options)
: options(_options),
requestLoop(true),
serverInstanceDir(_options.serverInstanceDir, false),
resourceLocator(options.passengerRoot)
{
TRACE_POINT();
this->feedbackFd = feedbackFd;
UPDATE_TRACE_POINT();
generation = serverInstanceDir.getGeneration(options.generationNumber);
startListening();
accountsDatabase = boost::make_shared<AccountsDatabase>();
accountsDatabase->add("_passenger-status", options.adminToolStatusPassword, false,
Account::INSPECT_BASIC_INFO | Account::INSPECT_SENSITIVE_INFO |
Account::INSPECT_BACKTRACES | Account::INSPECT_REQUESTS);
accountsDatabase->add("_web_server", options.exitPassword, false, Account::EXIT);
messageServer = boost::make_shared<MessageServer>(
parseUnixSocketAddress(options.adminSocketAddress), accountsDatabase);
createFile(generation->getPath() + "/helper_agent.pid",
toString(getpid()), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (geteuid() == 0 && !options.userSwitching) {
lowerPrivilege(options.defaultUser, options.defaultGroup);
}
UPDATE_TRACE_POINT();
randomGenerator = boost::make_shared<RandomGenerator>();
// Check whether /dev/urandom is actually random.
// https://code.google.com/p/phusion-passenger/issues/detail?id=516
if (randomGenerator->generateByteString(16) == randomGenerator->generateByteString(16)) {
throw RuntimeException("Your random number device, /dev/urandom, appears to be broken. "
"It doesn't seem to be returning random data. Please fix this.");
}
UPDATE_TRACE_POINT();
loggerFactory = boost::make_shared<UnionStation::LoggerFactory>(options.loggingAgentAddress,
"logging", options.loggingAgentPassword);
spawnerFactory = boost::make_shared<SpawnerFactory>(poolLoop.safe,
resourceLocator, generation, boost::make_shared<SpawnerConfig>(randomGenerator));
pool = boost::make_shared<Pool>(poolLoop.safe.get(), spawnerFactory, loggerFactory,
randomGenerator);
pool->initialize();
pool->setMax(options.maxPoolSize);
//pool->setMaxPerApp(maxInstancesPerApp);
pool->setMaxIdleTime(options.poolIdleTime * 1000000);
requestHandler = boost::make_shared<RequestHandler>(requestLoop.safe,
requestSocket, pool, options);
messageServer->addHandler(boost::make_shared<RemoteController>(requestHandler, pool));
messageServer->addHandler(ptr(new ExitHandler(exitEvent)));
sigquitWatcher.set(requestLoop.loop);
sigquitWatcher.set(SIGQUIT);
sigquitWatcher.set<Server, &Server::onSigquit>(this);
sigquitWatcher.start();
UPDATE_TRACE_POINT();
writeArrayMessage(feedbackFd,
"initialized",
getRequestSocketFilename().c_str(),
messageServer->getSocketFilename().c_str(),
NULL);
boost::function<void ()> func = boost::bind(prestartWebApps,
resourceLocator,
options.defaultRubyCommand,
options.prestartUrls
);
prestarterThread = ptr(new oxt::thread(
boost::bind(runAndPrintExceptions, func, true)
));
}
示例12: options
Server(FileDescriptor feedbackFd, const AgentOptions &_options)
: options(_options),
requestLoop(true),
serverInstanceDir(options.webServerPid, options.tempDir, false),
resourceLocator(options.passengerRoot)
{
TRACE_POINT();
this->feedbackFd = feedbackFd;
UPDATE_TRACE_POINT();
generation = serverInstanceDir.getGeneration(options.generationNumber);
startListening();
accountsDatabase = AccountsDatabase::createDefault(generation,
options.userSwitching, options.defaultUser, options.defaultGroup);
accountsDatabase->add("_web_server", options.messageSocketPassword, false, Account::EXIT);
messageServer = ptr(new MessageServer(generation->getPath() + "/socket", accountsDatabase));
createFile(generation->getPath() + "/helper_agent.pid",
toString(getpid()), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (geteuid() == 0 && !options.userSwitching) {
lowerPrivilege(options.defaultUser, options.defaultGroup);
}
UPDATE_TRACE_POINT();
loggerFactory = make_shared<UnionStation::LoggerFactory>(options.loggingAgentAddress,
"logging", options.loggingAgentPassword);
randomGenerator = make_shared<RandomGenerator>();
spawnerFactory = make_shared<SpawnerFactory>(poolLoop.safe,
resourceLocator, generation, randomGenerator);
pool = make_shared<Pool>(poolLoop.safe.get(), spawnerFactory, loggerFactory,
randomGenerator);
pool->setMax(options.maxPoolSize);
//pool->setMaxPerApp(maxInstancesPerApp);
pool->setMaxIdleTime(options.poolIdleTime * 1000000);
messageServer->addHandler(make_shared<RemoteController>(pool));
messageServer->addHandler(make_shared<BacktracesServer>());
messageServer->addHandler(ptr(new ExitHandler(exitEvent)));
requestHandler = make_shared<RequestHandler>(requestLoop.safe,
requestSocket, pool, options);
sigquitWatcher.set(requestLoop.loop);
sigquitWatcher.set(SIGQUIT);
sigquitWatcher.set<Server, &Server::onSigquit>(this);
sigquitWatcher.start();
UPDATE_TRACE_POINT();
writeArrayMessage(feedbackFd,
"initialized",
getRequestSocketFilename().c_str(),
messageServer->getSocketFilename().c_str(),
NULL);
function<void ()> func = boost::bind(prestartWebApps,
resourceLocator,
options.prestartUrls
);
prestarterThread = ptr(new oxt::thread(
boost::bind(runAndPrintExceptions, func, true)
));
}