summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2017-02-07 19:38:33 +0100
committerMatteo Collina <hello@matteocollina.com>2017-02-13 09:08:47 +0100
commitb1fc7745f2c7f279d388d8c88781df776b740259 (patch)
tree3fc4489218939e72fb845950756ab76a216ef701 /test
parent6dd979e67ce43beae56b06ed703ad8bd6a8f4370 (diff)
downloadandroid-node-v8-b1fc7745f2c7f279d388d8c88781df776b740259.tar.gz
android-node-v8-b1fc7745f2c7f279d388d8c88781df776b740259.tar.bz2
android-node-v8-b1fc7745f2c7f279d388d8c88781df776b740259.zip
fs: avoid emitting error EBADF for double close
Changed the logic in fs.ReadStream and fs.WriteStream so that close always calls the prototype method rather than the internal event listener. Fixes: https://github.com/nodejs/node/issues/2950 PR-URL: https://github.com/nodejs/node/pull/11225 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-fs-read-stream-double-close.js11
-rw-r--r--test/parallel/test-fs-write-stream-double-close.js14
2 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-fs-read-stream-double-close.js b/test/parallel/test-fs-read-stream-double-close.js
new file mode 100644
index 0000000000..e18bc6b4fb
--- /dev/null
+++ b/test/parallel/test-fs-read-stream-double-close.js
@@ -0,0 +1,11 @@
+'use strict';
+
+const common = require('../common');
+const fs = require('fs');
+
+const s = fs.createReadStream(__filename);
+
+s.close(common.mustCall(noop));
+s.close(common.mustCall(noop));
+
+function noop() {}
diff --git a/test/parallel/test-fs-write-stream-double-close.js b/test/parallel/test-fs-write-stream-double-close.js
new file mode 100644
index 0000000000..935d58eaef
--- /dev/null
+++ b/test/parallel/test-fs-write-stream-double-close.js
@@ -0,0 +1,14 @@
+'use strict';
+
+const common = require('../common');
+const fs = require('fs');
+const path = require('path');
+
+common.refreshTmpDir();
+
+const s = fs.createWriteStream(path.join(common.tmpDir, 'rw'));
+
+s.close(common.mustCall(noop));
+s.close(common.mustCall(noop));
+
+function noop() {}