Пример #1
0
Status TransportLayerLegacy::_runTicket(Ticket ticket) {
    if (!_running.load()) {
        return TransportLayer::ShutdownStatus;
    }

    if (ticket.expiration() < Date_t::now()) {
        return Ticket::ExpiredStatus;
    }

    AbstractMessagingPort* amp;

    {
        stdx::lock_guard<stdx::mutex> lk(_connectionsMutex);

        auto conn = _connections.find(ticket.sessionId());
        if (conn == _connections.end()) {
            return TransportLayer::TicketSessionUnknownStatus;
        }

        // "check out" the port
        conn->second.inUse = true;
        amp = conn->second.amp.get();
    }

    auto legacyTicket = checked_cast<LegacyTicket*>(getTicketImpl(ticket));
    auto res = legacyTicket->_fill(amp);

    {
        stdx::lock_guard<stdx::mutex> lk(_connectionsMutex);

        auto conn = _connections.find(ticket.sessionId());
        invariant(conn != _connections.end());

#ifdef MONGO_CONFIG_SSL
        // If we didn't have an X509 subject name, see if we have one now
        if (!conn->second.sslPeerInfo) {
            auto info = amp->getX509PeerInfo();
            if (info.subjectName != "") {
                conn->second.sslPeerInfo = info;
            }
        }
#endif
        conn->second.inUse = false;

        if (conn->second.ended) {
            Listener::globalTicketHolder.release();
            _connections.erase(conn);
        }
    }

    return res;
}
Пример #2
0
Status TransportLayerLegacy::_runTicket(Ticket ticket) {
    if (!_running.load()) {
        return TransportLayer::ShutdownStatus;
    }

    if (ticket.expiration() < Date_t::now()) {
        return Ticket::ExpiredStatus;
    }

    // get the weak_ptr out of the ticket
    // attempt to make it into a shared_ptr
    auto legacyTicket = checked_cast<LegacyTicket*>(getTicketImpl(ticket));
    auto session = legacyTicket->getSession();
    if (!session) {
        return TransportLayer::TicketSessionClosedStatus;
    }

    auto conn = session->conn();
    if (conn->closed) {
        return TransportLayer::TicketSessionClosedStatus;
    }

    Status res = Status::OK();
    try {
        res = legacyTicket->fill(conn->amp.get());
    } catch (...) {
        res = exceptionToStatus();
    }

#ifdef MONGO_CONFIG_SSL
    // If we didn't have an X509 subject name, see if we have one now
    auto& sslPeerInfo = SSLPeerInfo::forSession(legacyTicket->getSession());
    if (sslPeerInfo.subjectName.empty()) {
        auto info = conn->amp->getX509PeerInfo();
        if (!info.subjectName.empty()) {
            sslPeerInfo = info;
        }
    }
#endif

    return res;
}