MCPcopy Create free account
hub / github.com/apple/foundationdb / doAcceptHandshake

Method doAcceptHandshake

flow/Net2.actor.cpp:906–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904 }
905
906 ACTOR static void doAcceptHandshake(Reference<SSLConnection> self, Promise<Void> connected) {
907 state Hold<int> holder;
908
909 try {
910 Future<Void> onHandshook;
911 ConfigureSSLStream(N2::g_net2->activeTlsPolicy, self->ssl_sock, [this](bool verifyOk) {
912 self->has_trusted_peer = verifyOk;
913 });
914
915 // If the background handshakers are not all busy, use one
916 if (N2::g_net2->sslPoolHandshakesInProgress < N2::g_net2->sslHandshakerThreadsStarted) {
917 holder = Hold(&N2::g_net2->sslPoolHandshakesInProgress);
918 auto handshake =
919 new SSLHandshakerThread::Handshake(self->ssl_sock, boost::asio::ssl::stream_base::server);
920 onHandshook = handshake->done.getFuture();
921 N2::g_net2->sslHandshakerPool->post(handshake);
922 } else {
923 // Otherwise use flow network thread
924 BindPromise p("N2_AcceptHandshakeError", UID());
925 onHandshook = p.getFuture();
926 self->ssl_sock.async_handshake(boost::asio::ssl::stream_base::server, std::move(p));
927 }
928 wait(onHandshook);
929 wait(delay(0, TaskPriority::Handshake));
930 connected.send(Void());
931 } catch (...) {
932 self->closeSocket();
933 connected.sendError(connection_failed());
934 }
935 }
936
937 ACTOR static Future<Void> acceptHandshakeWrapper(Reference<SSLConnection> self) {
938 state std::pair<IPAddress, uint16_t> peerIP;

Callers

nothing calls this directly

Calls 11

ConfigureSSLStreamFunction · 0.85
HoldClass · 0.85
UIDClass · 0.85
moveFunction · 0.85
delayFunction · 0.85
VoidClass · 0.70
getFutureMethod · 0.45
postMethod · 0.45
sendMethod · 0.45
closeSocketMethod · 0.45
sendErrorMethod · 0.45

Tested by

no test coverage detected