This repository was archived by the owner on Feb 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 66#include <sys/types.h>
77#include <sys/stat.h>
88#include <sys/wait.h>
9+ #include <sys/resource.h>
910#include <fcntl.h>
1011#include <dirent.h>
1112#include <sched.h>
@@ -1144,6 +1145,7 @@ static int hyper_loop(void)
11441145 struct epoll_event * events ;
11451146 struct hyper_pod * pod = & global_pod ;
11461147 sigset_t mask , omask ;
1148+ struct rlimit limit ;
11471149
11481150 sigemptyset (& mask );
11491151 sigaddset (& mask , SIGCHLD );
@@ -1162,6 +1164,26 @@ static int hyper_loop(void)
11621164 sigdelset (& omask , SIGCHLD );
11631165 signal (SIGCHLD , hyper_init_sigchld );
11641166
1167+ // setup open file limit
1168+ limit .rlim_cur = limit .rlim_max = 1000000 ;
1169+ if (setrlimit (RLIMIT_NOFILE , & limit ) < 0 ) {
1170+ perror ("set rlimit for NOFILE failed" );
1171+ return -1 ;
1172+ }
1173+
1174+ // setup process num limit
1175+ limit .rlim_cur = limit .rlim_max = 30604 ;
1176+ if (setrlimit (RLIMIT_NPROC , & limit ) < 0 ) {
1177+ perror ("set rlimit for NPROC failed" );
1178+ return -1 ;
1179+ }
1180+
1181+ // setup pending signal limit, same with NRPROC
1182+ if (setrlimit (RLIMIT_SIGPENDING , & limit ) < 0 ) {
1183+ perror ("set rlimit for SIGPENDING failed" );
1184+ return -1 ;
1185+ }
1186+
11651187 ctl .efd = epoll_create1 (EPOLL_CLOEXEC );
11661188 if (ctl .efd < 0 ) {
11671189 perror ("epoll_create failed" );
You can’t perform that action at this time.
0 commit comments