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
@@ -521,6 +521,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:
