diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-05 16:02:20 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-05 16:02:20 +0100 |
commit | fbf345e03e3aaf2e98924dee96de736291f68d3f (patch) | |
tree | 59ce29d8cd70e5b79a4a3c6812236b84bc30da61 | |
parent | b2be8466fb1aa54aaeb07b93ee9d44614518a01c (diff) | |
download | serenity-fbf345e03e3aaf2e98924dee96de736291f68d3f.zip |
Inspector: Handle multi-packet RPC responses
This makes it possible to connect to Minesweeper, which has a rather
huge widget tree. :^)
-rw-r--r-- | DevTools/Inspector/RemoteProcess.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/DevTools/Inspector/RemoteProcess.cpp b/DevTools/Inspector/RemoteProcess.cpp index 189f4a3dba..66a412d8a9 100644 --- a/DevTools/Inspector/RemoteProcess.cpp +++ b/DevTools/Inspector/RemoteProcess.cpp @@ -44,6 +44,7 @@ RemoteProcess::RemoteProcess(pid_t pid) , m_socket(Core::LocalSocket::construct()) { s_the = this; + m_socket->set_blocking(true); } void RemoteProcess::handle_identify_response(const JsonObject& response) @@ -151,10 +152,19 @@ void RemoteProcess::update() int nread = m_socket->read((u8*)&length, sizeof(length)); ASSERT(nread == sizeof(length)); - auto data = m_socket->read(length); - ASSERT(data.size() == length); + ByteBuffer data; + size_t remaining_bytes = length; + + while (remaining_bytes) { + auto packet = m_socket->read(remaining_bytes); + if (packet.size() == 0) + break; + data.append(packet.data(), packet.size()); + remaining_bytes -= packet.size(); + } - dbg() << "Got packet size " << length << " and read that many bytes"; + ASSERT(data.size() == length); + dbg() << "Got data size " << length << " and read that many bytes"; auto json_value = JsonValue::from_string(data); ASSERT(json_value.is_object()); |