|
|
@ -92,6 +92,7 @@ function Socket (peerInfo) { |
|
|
|
debug('recvBuffer.used ' + recvBuffer.used); |
|
|
|
var bytesRead; |
|
|
|
|
|
|
|
try { |
|
|
|
if (self.type == "unix") { |
|
|
|
bytesRead = recvMsg(self.fd, |
|
|
|
recvBuffer, |
|
|
@ -107,6 +108,10 @@ function Socket (peerInfo) { |
|
|
|
recvBuffer.used, |
|
|
|
recvBuffer.length - recvBuffer.used); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
self.forceClose(e); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
debug('bytesRead ' + bytesRead + '\n'); |
|
|
|
|
|
|
@ -320,6 +325,8 @@ Socket.prototype.flush = function () { |
|
|
|
} |
|
|
|
|
|
|
|
var fdToSend = null; |
|
|
|
|
|
|
|
try { |
|
|
|
if (b.isFd) { |
|
|
|
fdToSend = parseInt(b.asciiSlice(b.sent, b.used - b.sent)); |
|
|
|
bytesWritten = sendFD(self.fd, fdToSend); |
|
|
@ -329,6 +336,11 @@ Socket.prototype.flush = function () { |
|
|
|
b.sent, |
|
|
|
b.used - b.sent); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
self.forceClose(e); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (bytesWritten === null) { |
|
|
|
// could not flush everything
|
|
|
|
self._writeWatcher.start(); |
|
|
@ -451,7 +463,14 @@ Socket.prototype.forceClose = function (exception) { |
|
|
|
Socket.prototype._shutdown = function () { |
|
|
|
if (this.writable) { |
|
|
|
this.writable = false; |
|
|
|
shutdown(this.fd, 'write'); |
|
|
|
|
|
|
|
try { |
|
|
|
shutdown(this.fd, 'write') |
|
|
|
} catch (e) { |
|
|
|
this.forceClose(e); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (!this.readable) this.forceClose(); |
|
|
|
} |
|
|
|
}; |
|
|
|