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

LibCore: Remove unused "client ID" from InspectorServerConnection

This was sharing an ID allocator with event loop timers for some reason.
More importantly, it wasn't actually used for anything.
This commit is contained in:
Andreas Kling 2023-04-24 07:45:36 +02:00
parent 8e7d7b0ec2
commit a6a2caf6db

View file

@ -168,9 +168,6 @@ class InspectorServerConnection : public Object {
private: private:
explicit InspectorServerConnection(NonnullOwnPtr<LocalSocket> socket) explicit InspectorServerConnection(NonnullOwnPtr<LocalSocket> socket)
: m_socket(move(socket)) : m_socket(move(socket))
, m_client_id(s_id_allocator.with_locked([](auto& allocator) {
return allocator->allocate();
}))
{ {
#ifdef AK_OS_SERENITY #ifdef AK_OS_SERENITY
m_socket->on_ready_to_read = [this] { m_socket->on_ready_to_read = [this] {
@ -178,14 +175,12 @@ private:
auto maybe_bytes_read = m_socket->read_some({ (u8*)&length, sizeof(length) }); auto maybe_bytes_read = m_socket->read_some({ (u8*)&length, sizeof(length) });
if (maybe_bytes_read.is_error()) { if (maybe_bytes_read.is_error()) {
dbgln("InspectorServerConnection: Failed to read message length from inspector server connection: {}", maybe_bytes_read.error()); dbgln("InspectorServerConnection: Failed to read message length from inspector server connection: {}", maybe_bytes_read.error());
shutdown();
return; return;
} }
auto bytes_read = maybe_bytes_read.release_value(); auto bytes_read = maybe_bytes_read.release_value();
if (bytes_read.is_empty()) { if (bytes_read.is_empty()) {
dbgln_if(EVENTLOOP_DEBUG, "RPC client disconnected"); dbgln_if(EVENTLOOP_DEBUG, "RPC client disconnected");
shutdown();
return; return;
} }
@ -195,7 +190,6 @@ private:
maybe_bytes_read = m_socket->read_some(request_buffer.bytes()); maybe_bytes_read = m_socket->read_some(request_buffer.bytes());
if (maybe_bytes_read.is_error()) { if (maybe_bytes_read.is_error()) {
dbgln("InspectorServerConnection: Failed to read message content from inspector server connection: {}", maybe_bytes_read.error()); dbgln("InspectorServerConnection: Failed to read message content from inspector server connection: {}", maybe_bytes_read.error());
shutdown();
return; return;
} }
@ -204,7 +198,6 @@ private:
auto request_json = JsonValue::from_string(request_buffer); auto request_json = JsonValue::from_string(request_buffer);
if (request_json.is_error() || !request_json.value().is_object()) { if (request_json.is_error() || !request_json.value().is_object()) {
dbgln("RPC client sent invalid request"); dbgln("RPC client sent invalid request");
shutdown();
return; return;
} }
@ -301,22 +294,11 @@ public:
} }
return; return;
} }
if (type == "Disconnect") {
shutdown();
return;
}
}
void shutdown()
{
s_id_allocator.with_locked([this](auto& allocator) { allocator->deallocate(m_client_id); });
} }
private: private:
NonnullOwnPtr<LocalSocket> m_socket; NonnullOwnPtr<LocalSocket> m_socket;
WeakPtr<Object> m_inspected_object; WeakPtr<Object> m_inspected_object;
int m_client_id { -1 };
}; };
EventLoop::EventLoop([[maybe_unused]] MakeInspectable make_inspectable) EventLoop::EventLoop([[maybe_unused]] MakeInspectable make_inspectable)