|
|
@ -296,11 +296,27 @@ function initStream (self) { |
|
|
|
try { |
|
|
|
if (self.secure) { |
|
|
|
if (!securePool) allocNewSecurePool(); |
|
|
|
secureBytesRead = read(self.fd, securePool, 0, securePool.length); |
|
|
|
self.secureStream.readInject(securePool, 0, secureBytesRead); |
|
|
|
bytesRead = self.secureStream.readExtract(pool, |
|
|
|
pool.used, |
|
|
|
pool.length - pool.used); |
|
|
|
var calledByNextTick = (arguments.length == 0); // IOWatcher always passes arguments
|
|
|
|
if (!calledByNextTick) { |
|
|
|
secureBytesRead = read(self.fd, securePool, 0, securePool.length); |
|
|
|
self.secureStream.readInject(securePool, 0, secureBytesRead); |
|
|
|
} |
|
|
|
var chunkBytes; |
|
|
|
bytesRead = 0; |
|
|
|
do { |
|
|
|
chunkBytes = self.secureStream.readExtract(pool, |
|
|
|
pool.used + bytesRead, |
|
|
|
pool.length - pool.used - bytesRead); |
|
|
|
bytesRead += chunkBytes; |
|
|
|
} while ((chunkBytes > 0) && (pool.used + bytesRead < pool.length)); |
|
|
|
if (bytesRead == 0 && calledByNextTick) |
|
|
|
return; |
|
|
|
if (self.secureStream.readPending()) { |
|
|
|
process.nextTick(function () { |
|
|
|
if(self._readWatcher) |
|
|
|
self._readWatcher.callback(); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!self.secureEstablished) { |
|
|
|
if (self.secureStream.isInitFinished()) { |
|
|
|
self.secureEstablished = true; |
|
|
|