iSulad/0028-increase-websocket-lws_lookup-size.patch
zhangxiaoyu 07838725fd sync from upstream openeuler/iSulad
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2022-06-21 19:17:57 +08:00

42 lines
1.8 KiB
Diff

From 2ca552a7faee850c6cfdccc4625b4459add56074 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 21 Jun 2022 17:34:23 +0800
Subject: [PATCH 28/28] increase websocket lws_lookup size
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/daemon/entry/cri/websocket/service/ws_server.cc | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/daemon/entry/cri/websocket/service/ws_server.cc b/src/daemon/entry/cri/websocket/service/ws_server.cc
index 0e462737..98c0fee0 100644
--- a/src/daemon/entry/cri/websocket/service/ws_server.cc
+++ b/src/daemon/entry/cri/websocket/service/ws_server.cc
@@ -187,7 +187,13 @@ void WebsocketServer::EmitLog(int level, const char *line)
int WebsocketServer::CreateContext()
{
- const size_t WS_ULIMIT_FDS { 1024 };
+ /*
+ context->lws_lookup is allocated ( sizeof(struct lws *) * max_fds ) spaces,
+ In general, max_fds should be the process maximum number of open file descriptor.
+ If WS_ULIMIT_FDS set too large, context->lws_lookup will cost too much memory.
+ If WS_ULIMIT_FDS set too small, maybe fd > max_fds and context->lws_lookup[fd] will overflow.
+ */
+ const size_t WS_ULIMIT_FDS { 10240 };
m_url.SetScheme("ws");
m_url.SetHost("localhost:" + std::to_string(m_listenPort));
@@ -208,7 +214,7 @@ int WebsocketServer::CreateContext()
/* daemon set RLIMIT_NOFILE to a large value at main.c,
* belowing lws_create_context limit the fds of websocket to RLIMIT_NOFILE,
- * and malloced memory according to it. To reduce memory, we recover it to 1024 before create m_context.
+ * and malloced memory according to it. To reduce memory, we recover it to WS_ULIMIT_FDS before create m_context.
*/
rlimit oldLimit, newLimit;
newLimit.rlim_cur = WS_ULIMIT_FDS;
--
2.25.1