File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1095,7 +1095,7 @@ newDevPollObject(PyObject *module)
10951095 struct rlimit limit ;
10961096
10971097 /*
1098- ** If we try to process more that getrlimit()
1098+ ** If we try to process more than getrlimit()
10991099 ** fds, the kernel will give an error, so
11001100 ** we set the limit here. It is a dynamic
11011101 ** value, because we can change rlimit() anytime.
@@ -1106,6 +1106,15 @@ newDevPollObject(PyObject *module)
11061106 return NULL ;
11071107 }
11081108
1109+ /*
1110+ ** If the limit is too high (or RLIM_INFINITY), we might allocate huge
1111+ ** amounts of memory (or even fail to allocate). Because of that, we limit
1112+ ** the number of allocated structs to 2^18 (which is ~4MB of memory).
1113+ */
1114+ if (limit .rlim_cur > (rlim_t )262144 ) {
1115+ limit .rlim_cur = (rlim_t )262144 ;
1116+ }
1117+
11091118 fd_devpoll = _Py_open ("/dev/poll" , O_RDWR );
11101119 if (fd_devpoll == -1 )
11111120 return NULL ;
You can’t perform that action at this time.
0 commit comments