1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Description: Workaround using too much resource
With systemd >= 256~rc3-3, NOFILE is really big by default. Therefore,
the code doing:
.
for fd in reversed(range(maxfd)):
.
is in fact using *a lot* of resources.
.
This patch attemps to fix this.
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1075849
Forwarded: https://github.com/novnc/websockify/pull/581
Last-Update: 2024-07-16
Index: websockify/websockify/websockifyserver.py
===================================================================
--- websockify.orig/websockify/websockifyserver.py
+++ websockify/websockify/websockifyserver.py
@@ -522,6 +522,12 @@ class WebSockifyServer():
# Close open files
maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
if maxfd == resource.RLIM_INFINITY: maxfd = 256
+ # Since Systemd 256~rc3-3, maxfd could be
+ # *really* big, and therefore, the below code
+ # could take too much resources. This somehow
+ # attemps to limit this.
+ if maxfd > 4096:
+ maxfd = 4096
for fd in reversed(range(maxfd)):
try:
if fd not in keepfd:
|