Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file descriptor leak on /dev/urandom each time nginx reloads #6

Merged
merged 1 commit into from
Feb 22, 2015

Commits on Feb 22, 2015

  1. Fix file descriptor leak on /dev/urandom each time nginx reloads.

    Each time nginx was reloaded (via the HUP signal), it was opening new
    handles to /dev/urandom for each worker process, but failing to close
    the old unused ones. So if you had 4 worker processes, after 3 reloads,
    you'd have 16 total handles to /dev/urandom open with 12 of those being
    unused. This led to an indefinite leaking of file descriptors on the
    nginx master process, which could eventually culminate in "too many
    files open" errors killing nginx if you managed to reload nginx enough
    times to hit your system file descriptor limit.
    
    This shifts the /dev/urandom opening from the init_module into the
    init_process callback so that each worker process opens its own files.
    This then allows us to properly close those file descriptors each time a
    worker exits on reload via the exit_process callback.
    
    I'm not exactly sure how to test this within the context of Test::Nginx,
    but in some manual testing, this does seem to fix the file descriptor
    leak across repeated reloads.
    GUI committed Feb 22, 2015
    Configuration menu
    Copy the full SHA
    5116a6e View commit details
    Browse the repository at this point in the history