Clean up a few bugs in net.js
This commit is contained in:
parent
c106c3740b
commit
824a2fd1c6
11
lib/net.js
11
lib/net.js
@ -31,7 +31,7 @@ var ENOENT = process.ENOENT;
|
||||
var END_OF_FILE = 0;
|
||||
|
||||
function Socket (peerInfo) {
|
||||
process.EventEmitter.call();
|
||||
process.EventEmitter.call(this);
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -131,9 +131,8 @@ exports.createConnection = function (port, host) {
|
||||
Socket.prototype._allocateNewRecvBuf = function () {
|
||||
var self = this;
|
||||
|
||||
var newBufferSize = 1024; // TODO make this adjustable from user API
|
||||
var newBufferSize = 128; // TODO make this adjustable from user API
|
||||
|
||||
/*
|
||||
if (toRead) {
|
||||
// Is the extra system call even worth it?
|
||||
var bytesToRead = toRead(self.fd);
|
||||
@ -148,7 +147,6 @@ Socket.prototype._allocateNewRecvBuf = function () {
|
||||
newBufferSize = 128;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
self.recvBuffer = new process.Buffer(newBufferSize);
|
||||
self.recvBuffer.used = 0;
|
||||
@ -247,7 +245,7 @@ Socket.prototype.send = function (data, encoding) {
|
||||
|
||||
if (!self.writable) throw new Error('Socket is not writable');
|
||||
|
||||
if (self._sendQueueLast == END_OF_FILE) {
|
||||
if (self._sendQueueLast() == END_OF_FILE) {
|
||||
throw new Error('socket.close() called already; cannot write.');
|
||||
}
|
||||
|
||||
@ -281,7 +279,7 @@ Socket.prototype.sendFD = function(socketToPass) {
|
||||
|
||||
if (!self.writable) throw new Error('Socket is not writable');
|
||||
|
||||
if (self._sendQueueLast == END_OF_FILE) {
|
||||
if (self._sendQueueLast() == END_OF_FILE) {
|
||||
throw new Error('socket.close() called already; cannot write.');
|
||||
}
|
||||
|
||||
@ -453,6 +451,7 @@ Socket.prototype.close = function () {
|
||||
|
||||
|
||||
function Server (listener) {
|
||||
process.EventEmitter.call(this);
|
||||
var self = this;
|
||||
|
||||
if (listener) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user