mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibCore: Put a limit on how many unsent messages an IPC server queues
This patch adds a limit of 200 unsent messages per client. If a client does not handle its incoming messages and we manage to queue up 200 messages for it, we'll now disconnect that client. :^)
This commit is contained in:
parent
31c1b8ec3e
commit
53cfed7c8b
Notes:
sideshowbarker
2024-07-19 11:27:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/53cfed7c8b8
@ -95,6 +95,12 @@ namespace Server {
|
||||
#endif
|
||||
if (try_send_message(message, extra_data))
|
||||
return;
|
||||
if (m_queue.size() >= max_queued_messages) {
|
||||
dbg() << "Connection::post_message: Client has too many queued messages already, disconnecting it.";
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
QueuedMessage queued_message { message, extra_data };
|
||||
if (!extra_data.is_empty())
|
||||
queued_message.message.extra_size = extra_data.size();
|
||||
@ -232,6 +238,8 @@ namespace Server {
|
||||
ServerMessage message;
|
||||
ByteBuffer extra_data;
|
||||
};
|
||||
|
||||
static const int max_queued_messages = 200;
|
||||
Queue<QueuedMessage, 16> m_queue;
|
||||
|
||||
int m_client_id { -1 };
|
||||
|
Loading…
Reference in New Issue
Block a user