sockets.push(socket);
socket.on('end', function() {
if (!this.closingOnPurpose)
- throw new Error('[c] closing by accident! ' + process._errno);
+ throw new Error('[c] closing by accident!');
});
}
+++ /dev/null
-// 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 common = require('../common');
-var assert = require('assert');
-
-if (process.argv[2] === 'child') {
- process.exit(0);
-} else {
- var spawn = require('child_process').spawn;
- var child = spawn(process.execPath, [process.argv[1], 'child']);
-
- var error = {};
- child.on('exit', function() {
- child._handle = {
- kill: function() {
- process._errno = 42;
- return -1;
- }
- };
- child.once('error', function(err) {
- error = err;
- });
- child.kill();
- });
-
- process.on('exit', function() {
- // we shouldn't reset errno since it accturlly isn't set
- // because of the fake .kill method
- assert.equal(error.syscall, 'kill');
- });
-}
processExited = true;
};
-pipe.onread = function(b, off, len) {
+pipe.onread = function(err, b, off, len) {
assert.ok(processExited);
if (b) {
gotPipeData = true;
var common = require('../common.js');
var assert = require('assert');
+var util = require('util');
+
+var errnoException = util._errnoException;
function parent() {
var spawn = require('child_process').spawn;
}
W.prototype._write = function(chunk, encoding, cb) {
- var req = handle.writeUtf8String(chunk.toString() + '\n');
+ var req = { oncomplete: afterWrite };
+ var err = handle.writeUtf8String(req, chunk.toString() + '\n');
+ if (err) throw errnoException(err, 'write');
// here's the problem.
// it needs to tell the Writable machinery that it's ok to write
// more, but that the current buffer length is handle.writeQueueSize
- req.oncomplete = afterWrite
if (req.writeQueueSize === 0)
req.cb = cb;
else
function makeConnection() {
var client = new TCP();
- var req = client.connect('127.0.0.1', common.PORT);
+ var req = {};
+ var err = client.connect(req, '127.0.0.1', common.PORT);
+ assert.equal(err, 0);
+
req.oncomplete = function(status, client_, req_) {
assert.equal(0, status);
assert.equal(client, client_);
assert.equal(req, req_);
console.log('connected');
- var shutdownReq = client.shutdown();
+ var shutdownReq = {};
+ var err = client.shutdown(shutdownReq);
+ assert.equal(err, 0);
+
shutdownReq.oncomplete = function(status, client_, req_) {
console.log('shutdown complete');
assert.equal(0, status);
var writeCount = 0;
var recvCount = 0;
-server.onconnection = function(client) {
+server.onconnection = function(err, client) {
assert.equal(0, client.writeQueueSize);
console.log('got connection');
client.readStart();
client.pendingWrites = [];
- client.onread = function(buffer) {
+ client.onread = function(err, buffer) {
if (buffer) {
assert.ok(buffer.length > 0);
assert.equal(0, client.writeQueueSize);
- var req = client.writeBuffer(buffer);
+ var req = {};
+ var err = client.writeBuffer(req, buffer);
+ assert.equal(err, 0);
client.pendingWrites.push(req);
console.log('client.writeQueueSize: ' + client.writeQueueSize);
assert.equal(1, writeCount);
assert.equal(1, recvCount);
});
-
-
var assert = require('assert');
var TCP = process.binding('tcp_wrap').TCP;
+var uv = process.binding('uv');
var handle = new TCP();
// Should be able to bind to the common.PORT
-var r = handle.bind('0.0.0.0', common.PORT);
-assert.equal(0, r);
+var err = handle.bind('0.0.0.0', common.PORT);
+assert.equal(err, 0);
// Should not be able to bind to the same port again
-var r = handle.bind('0.0.0.0', common.PORT);
-assert.equal(-1, r);
-console.log(process._errno);
-assert.equal(process._errno, 'EINVAL');
+err = handle.bind('0.0.0.0', common.PORT);
+assert.equal(err, uv.UV_EINVAL);
handle.close();