state.length += len;
var ret = state.length < state.highWaterMark;
- state.needDrain = !ret;
+ // we must ensure that previous needDrain will not be reset to false.
+ if (!ret)
+ state.needDrain = true;
- if (state.writing)
+ if (state.writing || state.corked)
state.buffer.push(new WriteReq(chunk, encoding, cb));
else
- doWrite(stream, state, len, chunk, encoding, cb);
+ doWrite(stream, state, false, len, chunk, encoding, cb);
return ret;
}
} else {
fprintf(stderr, "FATAL ERROR: %s\n", message);
}
- #if defined(DEBUG)
+ fflush(stderr);
abort();
- #endif
- exit(5);
}
-void FatalException(TryCatch &try_catch) {
- HandleScope scope;
- if (fatal_exception_symbol.IsEmpty())
- fatal_exception_symbol = NODE_PSYMBOL("_fatalException");
+NO_RETURN void FatalError(const char* location, const char* message) {
+ OnFatalError(location, message);
+ // to supress compiler warning
+ abort();
+}
- Local<Value> fatal_v = process->Get(fatal_exception_symbol);
- if (!fatal_v->IsFunction()) {
+void FatalException(Handle<Value> error, Handle<Message> message) {
+ HandleScope scope(node_isolate);
+
+ Environment* env = Environment::GetCurrent(node_isolate);
+ Local<Object> process_object = env->process_object();
+ Local<String> fatal_exception_string = env->fatal_exception_string();
+ Local<Function> fatal_exception_function =
+ process_object->Get(fatal_exception_string).As<Function>();
+
+ if (!fatal_exception_function->IsFunction()) {
// failed before the process._fatalException function was added!
// this is probably pretty bad. Nothing to do but report and exit.
- ReportException(try_catch, true);
+ ReportException(error, message);
exit(6);
}
Local<String> name, family;
Local<Array> ifarr;
- uv_err_t err = uv_interface_addresses(&interfaces, &count);
+ int err = uv_interface_addresses(&interfaces, &count);
- if (err) {
- return ThrowUVException(err, "uv_interface_addresses");
- }
ret = Object::New();
- if (err.code == UV_ENOSYS)
- return scope.Close(ret);
-
- if (err.code != UV_OK)
- return ThrowException(UVException(err.code, "uv_interface_addresses"));
++ if (err == UV_ENOSYS) {
++ args.GetReturnValue().Set(ret);
++ } else if (err) {
++ return ThrowUVException(err, "uv_interface_addresses");
++ }
+
for (i = 0; i < count; i++) {
- name = String::New(interfaces[i].name);
+ name = OneByteString(node_isolate, interfaces[i].name);
if (ret->Has(name)) {
ifarr = Local<Array>::Cast(ret->Get(name));
} else {
--- /dev/null
-cmdline += ' --max-old-space-size=1 --max-new-space-size=1';
-cmdline += ' -e "setInterval(function() { new Buffer(1024); }, 1);"';
+ // Copyright Joyent, Inc. and other Node contributors.
+
+ // Permission is hereby granted, free of charge, to any person obtaining a
+ // copy of this software and associated documentation files (the
+ // "Software"), to deal in the Software without restriction, including
+ // without limitation the rights to use, copy, modify, merge, publish,
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
+ // persons to whom the Software is furnished to do so, subject to the
+ // following conditions:
+
+ // The above copyright notice and this permission notice shall be included
+ // in all copies or substantial portions of the Software.
+
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ var assert = require('assert');
+ var common = require('../common');
+
+ if (process.platform === 'win32') {
+ console.log('skipping test on windows');
+ process.exit(0);
+ }
+
+ var exec = require('child_process').exec;
+
+ var cmdline = 'ulimit -c 0; ' + process.execPath;
++cmdline += ' --max-old-space-size=4 --max-new-space-size=1';
++cmdline += ' -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"';
+
+ exec(cmdline, function(err, stdout, stderr) {
+ assert(err);
+ assert(stderr.toString().match(/abort/i));
+ });
connectCount++;
console.log('ready!');
cb(c, function() {
- console.error('>>> killing node process %d\n\n', nodeProcess.pid);
- nodeProcess.kill();
- done();
+ c.end();
+ c.on('end', function() {
+ console.error(
+ '>>> killing node process %d\n\n',
+ nodeProcess.pid);
+ nodeProcess.kill();
+ done();
+ });
});
});
- });
+ c.on('error', function(err) {
+ if (err.code !== 'ECONNREFUSED') throw err;
+ setTimeout(tryConnect, 10);
+ });
+ }
}
});
}