Skip to content

Instantly share code, notes, and snippets.

@mbroadst
Created March 10, 2025 16:58
Show Gist options
  • Select an option

  • Save mbroadst/b2b6172c1f4b6afc234a3b1df34c37c6 to your computer and use it in GitHub Desktop.

Select an option

Save mbroadst/b2b6172c1f4b6afc234a3b1df34c37c6 to your computer and use it in GitHub Desktop.
diff --git a/src/mongo/transport/asio/asio_session_impl.cpp b/src/mongo/transport/asio/asio_session_impl.cpp
index dd0bef9f0a8..7a4bd6e4160 100644
--- a/src/mongo/transport/asio/asio_session_impl.cpp
+++ b/src/mongo/transport/asio/asio_session_impl.cpp
@@ -46,6 +46,9 @@
#include "mongo/util/net/socket_utils.h"
#include "mongo/util/signal_handlers_synchronous.h"
+#include "mongo/util/concurrency/ticketholder.h"
+#include "mongo/db/admission/ticketholder_manager.h"
+
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kNetwork
namespace mongo::transport {
@@ -596,12 +599,22 @@ Future<void> CommonAsioSession::read(const MutableBufferSequence& buffers,
} else if (!_ranHandshake) {
invariant(asio::buffer_size(buffers) >= sizeof(MSGHEADER::Value));
+ boost::optional<Ticket> ticket = [&]() {
+ ServiceContext* svcCtx = cc().getServiceContext();
+ auto opCtx = cc().makeOperationContext();
+ MockAdmissionContext admCtx;
+ admission::TicketHolderManager* thm = admission::TicketHolderManager::get(svcCtx);
+ return thm->getTicketHolder(LockMode::MODE_IX)->waitForTicket(opCtx.get(), &admCtx);
+ }();
+
return opportunisticRead(_socket, buffers, baton)
.then([this, buffers]() mutable {
_ranHandshake = true;
return maybeHandshakeSSLForIngress(buffers);
})
- .then([this, buffers, baton](bool needsRead) mutable {
+ .then([this, buffers, baton, &ticket](bool needsRead) mutable {
+ ticket = boost::none;
+
if (needsRead) {
return read(buffers, baton);
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment