LibGUI/WindowServer: Rework packet serialization
Instead of sending while serializing (what even was that), we serialize the whole packet into a buffer which can be sent in one go. First of all this reduces the number of sends by a lot. This also fixes WindowServer ending up sending partial packets when client is not responsive. Previously we would just try sending once, if any send failed the send was aborted while partial packet was already transmitted. This lead to packet stream being out of sync leading to the client killing itself. Now we allow 64 KiB outgoing buffer per client. If this buffer ever fills up, we will not send partial packets.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/Array.h>
|
||||
#include <BAN/Function.h>
|
||||
#include <BAN/StringView.h>
|
||||
#include <BAN/UniqPtr.h>
|
||||
@@ -93,6 +94,9 @@ namespace LibGUI
|
||||
|
||||
BAN::ErrorOr<void> handle_resize_event(const EventPacket::ResizeWindowEvent&);
|
||||
|
||||
template<typename T>
|
||||
void send_packet(const T& packet, BAN::StringView function);
|
||||
|
||||
private:
|
||||
const int m_server_fd;
|
||||
const int m_epoll_fd;
|
||||
@@ -119,6 +123,11 @@ namespace LibGUI
|
||||
BAN::Function<void(EventPacket::MouseMoveEvent::event_t)> m_mouse_move_event_callback;
|
||||
BAN::Function<void(EventPacket::MouseScrollEvent::event_t)> m_mouse_scroll_event_callback;
|
||||
|
||||
size_t m_in_buffer_size { 0 };
|
||||
BAN::Array<uint8_t, 64 * 1024> m_in_buffer;
|
||||
|
||||
BAN::Array<uint8_t, 64 * 1024> m_out_buffer;
|
||||
|
||||
friend class BAN::UniqPtr<Window>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user