Esempio n. 1
0
std::unique_ptr<NetworkInterface> makeNetworkInterface(
    std::string instanceName,
    std::unique_ptr<NetworkConnectionHook> hook,
    std::unique_ptr<rpc::EgressMetadataHook> metadataHook,
    ConnectionPool::Options connPoolOptions) {

    if (!connPoolOptions.egressTagCloserManager && hasGlobalServiceContext()) {
        connPoolOptions.egressTagCloserManager =
            &EgressTagCloserManager::get(getGlobalServiceContext());
    }

    auto svcCtx = hasGlobalServiceContext() ? getGlobalServiceContext() : nullptr;
    return std::make_unique<NetworkInterfaceTL>(
        instanceName, connPoolOptions, svcCtx, std::move(hook), std::move(metadataHook));
}
Esempio n. 2
0
void ScriptEngine::setup() {
    if (!globalScriptEngine) {
        globalScriptEngine = new mozjs::MozJSScriptEngine();

        if (hasGlobalServiceContext()) {
            getGlobalServiceContext()->registerKillOpListener(globalScriptEngine);
        }
    }
}
Esempio n. 3
0
void ScriptEngine::setup() {
    if (getGlobalScriptEngine())
        return;

    setGlobalScriptEngine(new mozjs::MozJSScriptEngine());

    if (hasGlobalServiceContext()) {
        getGlobalServiceContext()->registerKillOpListener(getGlobalScriptEngine());
    }
}
Esempio n. 4
0
BSONArray storageEngineList() {
    if (!hasGlobalServiceContext())
        return BSONArray();

    std::unique_ptr<StorageFactoriesIterator> sfi(
        getGlobalServiceContext()->makeStorageFactoriesIterator());

    if (!sfi)
        return BSONArray();

    BSONArrayBuilder engineArrayBuilder;

    while (sfi->more()) {
        engineArrayBuilder.append(sfi->next()->getCanonicalName());
    }

    return engineArrayBuilder.arr();
}
Esempio n. 5
0
/**
 * The main loop for the implementation thread
 *
 * This owns the actual implementation scope (which needs to be created on this
 * child thread) and has essentially two transition paths:
 *
 * Standard: ProxyRequest -> ImplResponse
 *   Invoke _function. Serialize exceptions to _status.
 *
 * Shutdown: Shutdown -> _
 *   break out of the loop and return.
 */
void MozJSProxyScope::implThread() {
    if (hasGlobalServiceContext())
        Client::initThread("js");

    std::unique_ptr<MozJSImplScope> scope;

    // This will leave _status set for the first noop runOnImplThread(), which
    // captures the startup exception that way
    try {
        scope.reset(new MozJSImplScope(_engine));
        _implScope = scope.get();
    } catch (...) {
        _status = exceptionToStatus();
    }

    while (true) {
        stdx::unique_lock<stdx::mutex> lk(_mutex);
        _condvar.wait(
            lk, [this] { return _state == State::ProxyRequest || _state == State::Shutdown; });

        if (_state == State::Shutdown)
            break;

        try {
            _function();
        } catch (...) {
            _status = exceptionToStatus();
        }

        int exitCode;
        if (_implScope && _implScope->getQuickExit(&exitCode)) {
            scope.reset();
            quickExit(exitCode);
        }

        _state = State::ImplResponse;

        _condvar.notify_one();
    }
}