From bc45adcffac675a423d4d0e5a765650d73de952c Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 7 May 2010 12:50:36 -0700 Subject: [PATCH] Add binding.close to fs.readFile --- lib/fs.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/fs.js b/lib/fs.js index 610d053..dbfec12 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -53,12 +53,17 @@ fs.readFile = function (path, encoding_, callback) { function doRead() { // position is offset or null so we can read files on unseekable mediums binding.read(fd, buffer, offset, size - offset, offset || null, function (err, amount) { - if (err) { callback(err); return; } + if (err) { + callback(err); + binding.close(fd); + return; + } if (amount + offset < size) { offset += amount; doRead(); return; } + binding.close(fd); if (encoding) { try { callback(null, buffer.toString(encoding)); -- 2.7.4