libvncserver: fix hanging on connection if fd limit is too high. #626
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #600
Before a connection is established, libvncserver will loop from 0 ->
<max possible file descriptor>
and count how many file descriptors are currently in use. The file descriptor limit is usually 1024, so this doesn't take too long, but when you run this inside a Docker container, Docker will set the limit to one million or one billion.This is similar to a bug in Red Hat Package Manager (rpm), and their solution was to count the number of files inside
/proc/self/fd
instead (see rpm-software-management/rpm#444). This solution only works on Linux, but then again, the current behavior of looping over file descriptors and callingfctnl
isn't particularly portable either.If you need, I can add fallback code for non-Linux machines.