1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:07:34 +00:00

RequestServer: Use an OwnPtr for cached connections

Otherwise we'd end up trying to delete the wrong connection if a
connection made before us is deleted.
Fixes _some_ RequestServer spins (though not all...).
This commit also adds a small debug mechanism to RequestServer (which
can be enabled by turning REQUEST_SERVER_DEBUG on), that can dump all
the current active connections in the cache, what they're doing, and how
long they've been doing that by sending it a SIGINFO.
This commit is contained in:
Ali Mohammad Pur 2021-09-29 13:06:13 +03:30 committed by Andreas Kling
parent ef9b8ff0c7
commit 398435277b
5 changed files with 89 additions and 26 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Debug.h>
#include <AK/OwnPtr.h>
#include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h>
@ -16,9 +17,18 @@
int main(int, char**)
{
if (pledge("stdio inet accept unix rpath sendfd recvfd", nullptr) < 0) {
perror("pledge");
return 1;
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;
}
}
// Ensure the certificates are read out here.