diff options
-rw-r--r-- | AK/Debug.h.in | 4 | ||||
-rw-r--r-- | Meta/CMake/all_the_debug_macros.cmake | 1 | ||||
-rw-r--r-- | Userland/Services/RequestServer/ConnectionCache.cpp | 9 | ||||
-rw-r--r-- | Userland/Services/RequestServer/ConnectionCache.h | 4 |
4 files changed, 12 insertions, 6 deletions
diff --git a/AK/Debug.h.in b/AK/Debug.h.in index 39315df5e6..1ffc6294ec 100644 --- a/AK/Debug.h.in +++ b/AK/Debug.h.in @@ -346,6 +346,10 @@ #cmakedefine01 REGEX_DEBUG #endif +#ifndef REQUESTSERVER_DEBUG +#cmakedefine01 REQUESTSERVER_DEBUG +#endif + #ifndef RESIZE_DEBUG #cmakedefine01 RESIZE_DEBUG #endif diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index 93d4ea06c9..f3c3ca97df 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -145,6 +145,7 @@ set(PTHREAD_DEBUG ON) set(PTMX_DEBUG ON) set(REACHABLE_DEBUG ON) set(REGEX_DEBUG ON) +set(REQUESTSERVER_DEBUG ON) set(RESIZE_DEBUG ON) set(RESOURCE_DEBUG ON) set(ROUTING_DEBUG ON) diff --git a/Userland/Services/RequestServer/ConnectionCache.cpp b/Userland/Services/RequestServer/ConnectionCache.cpp index 32956a34cc..85ae1c66a2 100644 --- a/Userland/Services/RequestServer/ConnectionCache.cpp +++ b/Userland/Services/RequestServer/ConnectionCache.cpp @@ -5,6 +5,7 @@ */ #include "ConnectionCache.h" +#include <AK/Debug.h> #include <LibCore/EventLoop.h> namespace RequestServer::ConnectionCache { @@ -19,7 +20,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket) return; } - dbgln("Request for {} finished", url); + dbgln_if(REQUESTSERVER_DEBUG, "Request for {} finished", url); ConnectionKey key { url.host(), url.port_or_default() }; auto fire_off_next_job = [&](auto& cache) { @@ -40,7 +41,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket) connection->current_url = {}; connection->removal_timer->on_timeout = [ptr = connection.ptr(), &cache_entry = *it->value, key = it->key, &cache]() mutable { Core::deferred_invoke([&, key = move(key), ptr] { - dbgln("Removing no-longer-used connection {} (socket {})", ptr, ptr->socket); + dbgln_if(REQUESTSERVER_DEBUG, "Removing no-longer-used connection {} (socket {})", ptr, ptr->socket); auto did_remove = cache_entry.remove_first_matching([&](auto& entry) { return entry == ptr; }); VERIFY(did_remove); if (cache_entry.is_empty()) @@ -58,9 +59,9 @@ void request_did_finish(URL const& url, Core::Socket const* socket) if (!is_connected) { // Create another socket for the connection. connection->socket = SocketType::construct(nullptr); - dbgln("Creating a new socket for {} -> {}", url, connection->socket); + dbgln_if(REQUESTSERVER_DEBUG, "Creating a new socket for {} -> {}", url, connection->socket); } - dbgln("Running next job in queue for connection {} @{}", &connection, connection->socket); + dbgln_if(REQUESTSERVER_DEBUG, "Running next job in queue for connection {} @{}", &connection, connection->socket); auto request = connection->request_queue.take_first(); connection->timer.start(); connection->current_url = url; diff --git a/Userland/Services/RequestServer/ConnectionCache.h b/Userland/Services/RequestServer/ConnectionCache.h index 451edb718a..1f9d87c70e 100644 --- a/Userland/Services/RequestServer/ConnectionCache.h +++ b/Userland/Services/RequestServer/ConnectionCache.h @@ -105,14 +105,14 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job) } auto& connection = sockets_for_url[index]; if (!connection.has_started) { - dbgln("Immediately start request for url {} in {} - {}", url, &connection, connection.socket); + dbgln_if(REQUESTSERVER_DEBUG, "Immediately start request for url {} in {} - {}", url, &connection, connection.socket); connection.has_started = true; connection.removal_timer->stop(); connection.timer.start(); connection.current_url = url; start_job(*connection.socket); } else { - dbgln("Enqueue request for URL {} in {} - {}", url, &connection, connection.socket); + dbgln_if(REQUESTSERVER_DEBUG, "Enqueue request for URL {} in {} - {}", url, &connection, connection.socket); connection.request_queue.append(move(start_job)); } return connection; |