Skip to content

Commit

Permalink
Revert some more unused/exploratory changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyashton committed Jul 4, 2024
1 parent 1d291ac commit a2a90ac
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 46 deletions.
51 changes: 20 additions & 31 deletions src/enclave/rpc_sessions.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,11 @@ namespace ccf
std::unordered_map<ListenInterfaceID, std::shared_ptr<::tls::Cert>> certs;
std::shared_ptr<CustomProtocolSubsystem> custom_protocol_subsystem;

struct SessionData
{
ListenInterfaceID interface_id;
std::shared_ptr<ccf::Session> session = nullptr;

SessionData(ListenInterfaceID lid, const std::shared_ptr<ccf::Session>& s)
{
interface_id = lid;
session = s;
}
};

ccf::pal::Mutex lock;
std::unordered_map<ccf::tls::ConnID, SessionData> sessions;
std::unordered_map<
ccf::tls::ConnID,
std::pair<ListenInterfaceID, std::shared_ptr<ccf::Session>>>
sessions;
size_t sessions_peak = 0;

// Negative sessions are reserved for those originating from
Expand Down Expand Up @@ -431,7 +422,7 @@ namespace ccf
shared_from_this());
}
sessions.insert(std::make_pair(
id, SessionData(listen_interface_id, std::move(capped_session))));
id, std::make_pair(listen_interface_id, std::move(capped_session))));
per_listen_interface.open_sessions++;
per_listen_interface.peak_sessions = std::max(
per_listen_interface.peak_sessions,
Expand All @@ -452,15 +443,15 @@ namespace ccf
auto session = std::make_shared<QUICSessionImpl>(
rpc_map, id, listen_interface_id, writer_factory);
sessions.insert(std::make_pair(
id, SessionData(listen_interface_id, std::move(session))));
id, std::make_pair(listen_interface_id, std::move(session))));
}
else if (custom_protocol_subsystem)
{
// We know it's a custom protocol, but the session creation function
// hasn't been registered yet, so we keep a nullptr until the first
// udp::inbound message.
sessions.insert(
std::make_pair(id, SessionData(listen_interface_id, nullptr)));
std::make_pair(id, std::make_pair(listen_interface_id, nullptr)));
}
else
{
Expand Down Expand Up @@ -495,7 +486,7 @@ namespace ccf
per_listen_interface.http_configuration);

sessions.insert(std::make_pair(
id, SessionData(listen_interface_id, std::move(session))));
id, std::make_pair(listen_interface_id, std::move(session))));
per_listen_interface.open_sessions++;
per_listen_interface.peak_sessions = std::max(
per_listen_interface.peak_sessions,
Expand All @@ -516,7 +507,7 @@ namespace ccf
return nullptr;
}

return search->second.session;
return search->second.second;
}

bool reply_async(
Expand Down Expand Up @@ -550,7 +541,7 @@ namespace ccf
const auto search = sessions.find(id);
if (search != sessions.end())
{
auto it = listening_interfaces.find(search->second.interface_id);
auto it = listening_interfaces.find(search->second.first);
if (it != listening_interfaces.end())
{
it->second.open_sessions--;
Expand All @@ -572,20 +563,19 @@ namespace ccf
// There are no limits on outbound client sessions (we do not check any
// session caps here). We expect this type of session to be rare and
// want it to succeed even when we are busy.
// Client sessions also get no idle timeout.
if (app_protocol == "HTTP2")
{
auto session = std::make_shared<::http::HTTP2ClientSession>(
id, writer_factory, std::move(ctx));
sessions.insert(std::make_pair(id, SessionData("", session)));
sessions.insert(std::make_pair(id, std::make_pair("", session)));
sessions_peak = std::max(sessions_peak, sessions.size());
return session;
}
else if (app_protocol == "HTTP1")
{
auto session = std::make_shared<::http::HTTPClientSession>(
id, writer_factory, std::move(ctx));
sessions.insert(std::make_pair(id, SessionData("", session)));
sessions.insert(std::make_pair(id, std::make_pair("", session)));
sessions_peak = std::max(sessions_peak, sessions.size());
return session;
}
Expand All @@ -601,7 +591,7 @@ namespace ccf
auto id = get_next_client_id();
auto session = std::make_shared<::http::UnencryptedHTTPClientSession>(
id, writer_factory);
sessions.insert(std::make_pair(id, SessionData("", session)));
sessions.insert(std::make_pair(id, std::make_pair("", session)));
sessions_peak = std::max(sessions_peak, sessions.size());
return session;
}
Expand All @@ -628,7 +618,7 @@ namespace ccf
return;
}

search->second.session->handle_incoming_data({data, size});
search->second.second->handle_incoming_data({data, size});
});

DISPATCHER_SET_MESSAGE_HANDLER(
Expand All @@ -655,14 +645,14 @@ namespace ccf
"Ignoring udp::inbound for unknown or refused session: {}", id);
return;
}
else if (!search->second.session && custom_protocol_subsystem)
else if (!search->second.second && custom_protocol_subsystem)
{
LOG_DEBUG_FMT("Creating custom UDP session {}", id);

try
{
const auto& conn_id = search->first;
const auto& interface_id = search->second.interface_id;
const auto& interface_id = search->second.first;

auto iit = listening_interfaces.find(interface_id);
if (iit == listening_interfaces.end())
Expand All @@ -677,11 +667,10 @@ namespace ccf

const auto& interface = iit->second;

search->second.session =
custom_protocol_subsystem->create_session(
interface.app_protocol, conn_id, nullptr);
search->second.second = custom_protocol_subsystem->create_session(
interface.app_protocol, conn_id, nullptr);

if (!search->second.session)
if (!search->second.second)
{
LOG_DEBUG_FMT(
"Failure to create custom protocol session, ignoring "
Expand All @@ -698,7 +687,7 @@ namespace ccf
}
}

search->second.session->handle_incoming_data({data, size});
search->second.second->handle_incoming_data({data, size});
});
}
};
Expand Down
5 changes: 0 additions & 5 deletions src/host/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ namespace asynchost
behaviour = std::move(b);
}

SocketBehaviour<TCP>* get_behaviour()
{
return behaviour.get();
}

std::string get_host() const
{
return host;
Expand Down
5 changes: 0 additions & 5 deletions src/host/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,6 @@ namespace asynchost
behaviour = std::move(b);
}

SocketBehaviour<UDP>* get_behaviour()
{
return behaviour.get();
}

std::string get_host() const
{
return host;
Expand Down
5 changes: 0 additions & 5 deletions tests/infra/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def make_address(host, port=0):
DEFAULT_MAX_FRAME_SIZE = 16 * 1024

DEFAULT_FORWARDING_TIMEOUT_MS = 3000
DEFAULT_IDLE_TIMEOUT_MS = 5000

PRIMARY_RPC_INTERFACE = "primary_rpc_interface"
SECONDARY_RPC_INTERFACE = "secondary_rpc_interface"
Expand Down Expand Up @@ -187,7 +186,6 @@ class RPCInterface(Interface):
acme_configuration: Optional[str] = None
accepted_endpoints: Optional[str] = None
forwarding_timeout_ms: Optional[int] = DEFAULT_FORWARDING_TIMEOUT_MS
idle_timeout_ms: Optional[int] = DEFAULT_IDLE_TIMEOUT_MS
redirections: Optional[RedirectionConfig] = None
app_protocol: str = "HTTP1"

Expand Down Expand Up @@ -249,8 +247,6 @@ def to_json(interface):
r["accepted_endpoints"] = interface.accepted_endpoints
if interface.forwarding_timeout_ms:
r["forwarding_timeout_ms"] = interface.forwarding_timeout_ms
# None is a valid value here, so write regardless
r["idle_timeout_ms"] = interface.idle_timeout_ms
if interface.redirections:
r["redirections"] = RedirectionConfig.to_json(interface.redirections)
return r
Expand All @@ -277,7 +273,6 @@ def from_json(json):
interface.forwarding_timeout_ms = json.get(
"forwarding_timeout_ms", DEFAULT_FORWARDING_TIMEOUT_MS
)
interface.idle_timeout_ms = json.get("idle_timeout_ms", DEFAULT_IDLE_TIMEOUT_MS)
if "redirections" in json:
interface.redirections = RedirectionConfig.from_json(json["redirections"])
if "endorsement" in json:
Expand Down

0 comments on commit a2a90ac

Please sign in to comment.