diff mbox series

[RFC] _rpc_dtablesize: Decrease the value of size.

Message ID tencent_990266C2252CF3FBEBDE512E5BEEA67CAF06@qq.com (mailing list archive)
State New, archived
Headers show
Series [RFC] _rpc_dtablesize: Decrease the value of size. | expand

Commit Message

Zhuohao Bai Oct. 25, 2023, 4:24 p.m. UTC
In the client code, the function _rpc_dtablesize() is used to determine the memory allocation for the __svc_xports array.

However, some operating systems (including the recent Manjaro OS) can have _SC_OPEN_MAX values as high as 1073741816, which can cause the __svc_xports array to become too large. This results in the process being killed.

There is a limit to the maximum number of files. To avoid this problem, a possible solution is to set the size to the lesser of 1024 and this value to ensure that the array space for open files is not too large, thus preventing the process from terminating.

Signed-off-by: Zhuohao Bai <zhuohao_bai@foxmail.com>
---
 src/rpc_dtablesize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/rpc_dtablesize.c b/src/rpc_dtablesize.c
index bce97e8..2027af4 100644
--- a/src/rpc_dtablesize.c
+++ b/src/rpc_dtablesize.c
@@ -41,7 +41,7 @@  _rpc_dtablesize(void)
 	static int size;
 
 	if (size == 0) {
-		size = sysconf(_SC_OPEN_MAX);
+		size = min(1024, sysconf(_SC_OPEN_MAX));
 	}
 	return (size);
 }