镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fs: fix fd leak on early readstream destroy - #81

Closed
mafintosh wants to merge 1 commit into
nodejs:v0.12from
mafintosh:fs-destroy-leak
Closed

mafintosh wants to merge 1 commit into
nodejs:v0.12from
mafintosh:fs-destroy-leak

Conversation

@mafintosh

Copy link
Copy Markdown
Member

Currently the following leaks a file descriptor

var fs = require('fs')

var rs = fs.createReadStream('my-file.txt')

rs.on('close', function() {
  console.log('i am never fired')
})

rs.destroy()

In fact if you call rs.destroy() before open has been emitted in general the read stream never closes.

This PR fixes that by calling .close() when the file descriptor is opened incase the stream has been destroyed in the meanwhile

@mafintosh

Copy link
Copy Markdown
Member Author

Oh I see this is a dup of #56. Closing.

@mafintosh mafintosh closed this Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant