mirror of https://github.com/nodejs/node.git
Fix: fs.open callback did not fire
Problem: Omitting the mode parameter causes the provided callback parameter to never fire. This was originally fixed inv0.7.4-release6078c37b
and later broken in5f2e9093
. Solution: Overwriting the value of a parameter also overwrites the reference in the arguments object. This patch works arround this fact by not touching the mode parameter until a reference to the callback has been established.
parent
a293f90db4
commit
29b0dc4ec8
|
@ -185,10 +185,11 @@ function modeNum(m, def) {
|
|||
}
|
||||
|
||||
fs.open = function(path, flags, mode, callback) {
|
||||
mode = modeNum(mode, '0666');
|
||||
var callback_ = arguments[arguments.length - 1];
|
||||
var callback = (typeof(callback_) == 'function' ? callback_ : null);
|
||||
|
||||
mode = modeNum(mode, '0666');
|
||||
|
||||
binding.open(path, stringToFlags(flags), mode, callback || noop);
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
|
||||
var openFd;
|
||||
fs.open(__filename, 'r', function(err, fd) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
openFd = fd;
|
||||
});
|
||||
|
||||
process.addListener('exit', function() {
|
||||
assert.ok(openFd);
|
||||
});
|
||||
|
Loading…
Reference in New Issue