summaryrefslogtreecommitdiff
path: root/Userland/Services/RequestServer
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-06 17:16:25 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-06 23:46:35 +0100
commit359d6e7b0b0ef7add9eb2015d0dd664a82cf73d7 (patch)
treebe51963e0f0dc7e1eeeb670188c8fe1fa5eea37f /Userland/Services/RequestServer
parent689ca370d4eca80eb5c3856a69c3eed4ed848a29 (diff)
downloadserenity-359d6e7b0b0ef7add9eb2015d0dd664a82cf73d7.zip
Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
Diffstat (limited to 'Userland/Services/RequestServer')
-rw-r--r--Userland/Services/RequestServer/ConnectionCache.cpp16
-rw-r--r--Userland/Services/RequestServer/ConnectionCache.h14
2 files changed, 15 insertions, 15 deletions
diff --git a/Userland/Services/RequestServer/ConnectionCache.cpp b/Userland/Services/RequestServer/ConnectionCache.cpp
index 4635cfc08c..1e70788015 100644
--- a/Userland/Services/RequestServer/ConnectionCache.cpp
+++ b/Userland/Services/RequestServer/ConnectionCache.cpp
@@ -11,8 +11,8 @@
namespace RequestServer::ConnectionCache {
-HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache {};
-HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache {};
+HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<Core::TCPSocket, Core::Socket>>>>> g_tcp_connection_cache {};
+HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<TLS::TLSv12>>>>> g_tls_connection_cache {};
void request_did_finish(URL const& url, Core::Socket const* socket)
{
@@ -85,10 +85,10 @@ void dump_jobs()
for (auto& connection : g_tls_connection_cache) {
dbgln(" - {}:{}", connection.key.hostname, connection.key.port);
for (auto& entry : *connection.value) {
- dbgln(" - Connection {} (started={}) (socket={})", &entry, entry.has_started, entry.socket);
- dbgln(" Currently loading {} ({} elapsed)", entry.current_url, entry.timer.is_valid() ? entry.timer.elapsed() : 0);
+ dbgln(" - Connection {} (started={}) (socket={})", &entry, entry->has_started, entry->socket);
+ dbgln(" Currently loading {} ({} elapsed)", entry->current_url, entry->timer.is_valid() ? entry->timer.elapsed() : 0);
dbgln(" Request Queue:");
- for (auto& job : entry.request_queue)
+ for (auto& job : entry->request_queue)
dbgln(" - {}", &job);
}
}
@@ -96,10 +96,10 @@ void dump_jobs()
for (auto& connection : g_tcp_connection_cache) {
dbgln(" - {}:{}", connection.key.hostname, connection.key.port);
for (auto& entry : *connection.value) {
- dbgln(" - Connection {} (started={}) (socket={})", &entry, entry.has_started, entry.socket);
- dbgln(" Currently loading {} ({} elapsed)", entry.current_url, entry.timer.is_valid() ? entry.timer.elapsed() : 0);
+ dbgln(" - Connection {} (started={}) (socket={})", &entry, entry->has_started, entry->socket);
+ dbgln(" Currently loading {} ({} elapsed)", entry->current_url, entry->timer.is_valid() ? entry->timer.elapsed() : 0);
dbgln(" Request Queue:");
- for (auto& job : entry.request_queue)
+ for (auto& job : entry->request_queue)
dbgln(" - {}", &job);
}
}
diff --git a/Userland/Services/RequestServer/ConnectionCache.h b/Userland/Services/RequestServer/ConnectionCache.h
index b7c8dd5c8a..8a9c27cfdb 100644
--- a/Userland/Services/RequestServer/ConnectionCache.h
+++ b/Userland/Services/RequestServer/ConnectionCache.h
@@ -121,8 +121,8 @@ struct AK::Traits<RequestServer::ConnectionCache::ConnectionKey> : public AK::Ge
namespace RequestServer::ConnectionCache {
-extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<Core::TCPSocket, Core::Socket>>>> g_tcp_connection_cache;
-extern HashMap<ConnectionKey, NonnullOwnPtr<NonnullOwnPtrVector<Connection<TLS::TLSv12>>>> g_tls_connection_cache;
+extern HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<Core::TCPSocket, Core::Socket>>>>> g_tcp_connection_cache;
+extern HashMap<ConnectionKey, NonnullOwnPtr<Vector<NonnullOwnPtr<Connection<TLS::TLSv12>>>>> g_tls_connection_cache;
void request_did_finish(URL const&, Core::Socket const*);
void dump_jobs();
@@ -178,12 +178,12 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
Proxy proxy { proxy_data };
- using ReturnType = decltype(&sockets_for_url[0]);
+ using ReturnType = decltype(sockets_for_url[0].ptr());
auto it = sockets_for_url.find_if([](auto& connection) { return connection->request_queue.is_empty(); });
auto did_add_new_connection = false;
auto failed_to_find_a_socket = it.is_end();
if (failed_to_find_a_socket && sockets_for_url.size() < ConnectionCache::MaxConcurrentConnectionsPerURL) {
- using ConnectionType = RemoveCVReference<decltype(cache.begin()->value->at(0))>;
+ using ConnectionType = RemoveCVReference<decltype(*cache.begin()->value->at(0))>;
auto connection_result = proxy.tunnel<typename ConnectionType::SocketType, typename ConnectionType::StorageType>(url);
if (connection_result.is_error()) {
dbgln("ConnectionCache: Connection to {} failed: {}", url, connection_result.error());
@@ -204,7 +204,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
socket_result.release_value(),
typename ConnectionType::QueueType {},
Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr).release_value_but_fixme_should_propagate_errors()));
- sockets_for_url.last().proxy = move(proxy);
+ sockets_for_url.last()->proxy = move(proxy);
did_add_new_connection = true;
}
size_t index;
@@ -216,7 +216,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
index = 0;
auto min_queue_size = (size_t)-1;
for (auto it = sockets_for_url.begin(); it != sockets_for_url.end(); ++it) {
- if (auto queue_size = it->request_queue.size(); min_queue_size > queue_size) {
+ if (auto queue_size = (*it)->request_queue.size(); min_queue_size > queue_size) {
index = it.index();
min_queue_size = queue_size;
}
@@ -232,7 +232,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job,
return ReturnType { nullptr };
}
- auto& connection = sockets_for_url[index];
+ auto& connection = *sockets_for_url[index];
if (!connection.has_started) {
if (auto result = recreate_socket_if_needed(connection, url); result.is_error()) {
dbgln("ConnectionCache: request failed to start, failed to make a socket: {}", result.error());