From 77f0e57b27baf0ae6e4aa8a7b8ff589290f7ddb7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 1 Oct 2021 19:59:51 +0200 Subject: [PATCH] RequestServer: Don't hide the SIGINFO state dump behind a debug macro Until we're confident that RequestServer doesn't need this runtime debug dump helper, it's much nicer if everyone has it built in, so they can simply send a SIGINFO if they see it acting up. --- AK/Debug.h.in | 4 ---- Meta/CMake/all_the_debug_macros.cmake | 1 - .../Services/RequestServer/ConnectionCache.cpp | 11 +++-------- .../Services/RequestServer/ConnectionCache.h | 8 ++------ Userland/Services/RequestServer/main.cpp | 17 +++++------------ 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/AK/Debug.h.in b/AK/Debug.h.in index 674006abb4..bd51a04e95 100644 --- a/AK/Debug.h.in +++ b/AK/Debug.h.in @@ -338,10 +338,6 @@ #cmakedefine01 REGEX_DEBUG #endif -#ifndef REQUEST_SERVER_DEBUG -#cmakedefine01 REQUEST_SERVER_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 c9d32d9a94..0787970f2c 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -141,7 +141,6 @@ set(PTHREAD_DEBUG ON) set(PTMX_DEBUG ON) set(REACHABLE_DEBUG ON) set(REGEX_DEBUG ON) -set(REQUEST_SERVER_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 f729eb03d5..32956a34cc 100644 --- a/Userland/Services/RequestServer/ConnectionCache.cpp +++ b/Userland/Services/RequestServer/ConnectionCache.cpp @@ -37,8 +37,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket) auto& connection = *connection_it; if (connection->request_queue.is_empty()) { connection->has_started = false; - if constexpr (REQUEST_SERVER_DEBUG) - connection->current_url = {}; + 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); @@ -63,10 +62,8 @@ void request_did_finish(URL const& url, Core::Socket const* socket) } dbgln("Running next job in queue for connection {} @{}", &connection, connection->socket); auto request = connection->request_queue.take_first(); - if constexpr (REQUEST_SERVER_DEBUG) { - connection->timer.start(); - connection->current_url = url; - } + connection->timer.start(); + connection->current_url = url; request(connection->socket); } }; @@ -79,7 +76,6 @@ void request_did_finish(URL const& url, Core::Socket const* socket) dbgln("Unknown socket {} finished for URL {}", *socket, url); } -#if REQUEST_SERVER_DEBUG void dump_jobs() { dbgln("=========== TLS Connection Cache =========="); @@ -105,6 +101,5 @@ void dump_jobs() } } } -#endif } diff --git a/Userland/Services/RequestServer/ConnectionCache.h b/Userland/Services/RequestServer/ConnectionCache.h index eba52f2b12..451edb718a 100644 --- a/Userland/Services/RequestServer/ConnectionCache.h +++ b/Userland/Services/RequestServer/ConnectionCache.h @@ -36,10 +36,8 @@ struct Connection { QueueType request_queue; NonnullRefPtr removal_timer; bool has_started { false }; -#if REQUEST_SERVER_DEBUG URL current_url {}; Core::ElapsedTimer timer {}; -#endif }; struct ConnectionKey { @@ -110,10 +108,8 @@ decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job) dbgln("Immediately start request for url {} in {} - {}", url, &connection, connection.socket); connection.has_started = true; connection.removal_timer->stop(); - if constexpr (REQUEST_SERVER_DEBUG) { - connection.timer.start(); - connection.current_url = url; - } + connection.timer.start(); + connection.current_url = url; start_job(*connection.socket); } else { dbgln("Enqueue request for URL {} in {} - {}", url, &connection, connection.socket); diff --git a/Userland/Services/RequestServer/main.cpp b/Userland/Services/RequestServer/main.cpp index a0a135c28a..0476603d11 100644 --- a/Userland/Services/RequestServer/main.cpp +++ b/Userland/Services/RequestServer/main.cpp @@ -17,20 +17,13 @@ int main(int, char**) { - if constexpr (REQUEST_SERVER_DEBUG) { - if (pledge("stdio inet accept unix rpath sendfd recvfd sigaction", nullptr) < 0) { - perror("pledge"); - return 1; - } - - signal(SIGINFO, [](int) { RequestServer::ConnectionCache::dump_jobs(); }); - } else { - if (pledge("stdio inet accept unix rpath sendfd recvfd", nullptr) < 0) { - perror("pledge"); - return 1; - } + if (pledge("stdio inet accept unix rpath sendfd recvfd sigaction", nullptr) < 0) { + perror("pledge"); + return 1; } + signal(SIGINFO, [](int) { RequestServer::ConnectionCache::dump_jobs(); }); + // Ensure the certificates are read out here. [[maybe_unused]] auto& certs = DefaultRootCACertificates::the();