mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00: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
1 changed files with 8 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue