Skip to content

Instantly share code, notes, and snippets.

@ryzokuken
Created May 9, 2018 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryzokuken/cc6c972c6ad2f6e3057ad8c15a132d1d to your computer and use it in GitHub Desktop.
Save ryzokuken/cc6c972c6ad2f6e3057ad8c15a132d1d to your computer and use it in GitHub Desktop.
Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
// If we are still connecting, then buffer this for later.
// The Writable logic will buffer up any more writes while
// waiting for this one to be done.
if (this.connecting) {
this._pendingData = data;
this._pendingEncoding = encoding;
this.once('connect', function connect() {
this._writeGeneric(writev, data, encoding, cb);
});
return;
}
this._pendingData = null;
this._pendingEncoding = '';
this._unrefTimer();
if (!this._handle) {
this.destroy(new ERR_SOCKET_CLOSED(), cb);
return false;
}
var req = createWriteWrap(this._handle, afterWrite);
if (writev)
writevGeneric(this, req, data, cb);
else
writeGeneric(this, req, data, encoding, cb);
if (req.async)
this[kLastWriteQueueSize] = req.bytes;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment