{"action":"created","issue":{"url":"https://api.github.com/repos/streadway/ngx_txid/issues/6","labels_url":"https://api.github.com/repos/streadway/ngx_txid/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/streadway/ngx_txid/issues/6/comments","events_url":"https://api.github.com/repos/streadway/ngx_txid/issues/6/events","html_url":"https://github.com/streadway/ngx_txid/pull/6","id":58506507,"number":6,"title":"Fix file descriptor leak on /dev/urandom each time nginx reloads","user":{"login":"GUI","id":12112,"avatar_url":"https://avatars.githubusercontent.com/u/12112?v=3","gravatar_id":"","url":"https://api.github.com/users/GUI","html_url":"https://github.com/GUI","followers_url":"https://api.github.com/users/GUI/followers","following_url":"https://api.github.com/users/GUI/following{/other_user}","gists_url":"https://api.github.com/users/GUI/gists{/gist_id}","starred_url":"https://api.github.com/users/GUI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GUI/subscriptions","organizations_url":"https://api.github.com/users/GUI/orgs","repos_url":"https://api.github.com/users/GUI/repos","events_url":"https://api.github.com/users/GUI/events{/privacy}","received_events_url":"https://api.github.com/users/GUI/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-22T15:38:55Z","updated_at":"2015-02-22T16:00:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/streadway/ngx_txid/pulls/6","html_url":"https://github.com/streadway/ngx_txid/pull/6","diff_url":"https://github.com/streadway/ngx_txid/pull/6.diff","patch_url":"https://github.com/streadway/ngx_txid/pull/6.patch"},"body":"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.\r\n\r\nThis 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.  \r\n\r\nI'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."},"comment":{"url":"https://api.github.com/repos/streadway/ngx_txid/issues/comments/75442018","html_url":"https://github.com/streadway/ngx_txid/pull/6#issuecomment-75442018","issue_url":"https://api.github.com/repos/streadway/ngx_txid/issues/6","id":75442018,"user":{"login":"hacfi","id":428841,"avatar_url":"https://avatars.githubusercontent.com/u/428841?v=3","gravatar_id":"","url":"https://api.github.com/users/hacfi","html_url":"https://github.com/hacfi","followers_url":"https://api.github.com/users/hacfi/followers","following_url":"https://api.github.com/users/hacfi/following{/other_user}","gists_url":"https://api.github.com/users/hacfi/gists{/gist_id}","starred_url":"https://api.github.com/users/hacfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hacfi/subscriptions","organizations_url":"https://api.github.com/users/hacfi/orgs","repos_url":"https://api.github.com/users/hacfi/repos","events_url":"https://api.github.com/users/hacfi/events{/privacy}","received_events_url":"https://api.github.com/users/hacfi/received_events","type":"User","site_admin":false},"created_at":"2015-02-22T16:00:44Z","updated_at":"2015-02-22T16:00:44Z","body":":+1: looks good"}}