aboutsummaryrefslogtreecommitdiff
path: root/src/tls_wrap.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2015-03-24 20:21:32 -0700
committerFedor Indutny <fedor@indutny.com>2015-03-25 17:51:05 -0500
commit2ccc8f3970cd1ed78585be37c8d912f3ccf56cd0 (patch)
treef9c26d3c0a12187edc1f3fd43f8267dbb9c67502 /src/tls_wrap.cc
parente74b5d278ca94bf27d16b3fb94cedf4c6fcac3ac (diff)
downloadandroid-node-v8-2ccc8f3970cd1ed78585be37c8d912f3ccf56cd0.tar.gz
android-node-v8-2ccc8f3970cd1ed78585be37c8d912f3ccf56cd0.tar.bz2
android-node-v8-2ccc8f3970cd1ed78585be37c8d912f3ccf56cd0.zip
tls_wrap: fix this incredibly stupid leak
Always call `Done` on the WriteWrap, and ensure that `EncOut` will consume all data in clear_in_ and invoke queued callbacks. Fix: https://github.com/iojs/io.js/issues/1075 PR-URL: https://github.com/iojs/io.js/pull/1244 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/tls_wrap.cc')
-rw-r--r--src/tls_wrap.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc
index b6b87b30ca..c774a8490b 100644
--- a/src/tls_wrap.cc
+++ b/src/tls_wrap.cc
@@ -90,8 +90,7 @@ TLSWrap::~TLSWrap() {
MakePending();
// And destroy
- while (WriteItem* wi = pending_write_items_.PopFront())
- delete wi;
+ InvokeQueued(UV_ECANCELED);
ClearError();
}
@@ -310,10 +309,12 @@ void TLSWrap::EncOut() {
write_req->Dispatched();
// Ignore errors, this should be already handled in js
- if (err)
+ if (err) {
write_req->Dispose();
- else
+ InvokeQueued(err);
+ } else {
NODE_COUNT_NET_BYTES_SENT(write_size_);
+ }
}
@@ -335,6 +336,9 @@ void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) {
// Commit
NodeBIO::FromBIO(wrap->enc_out_)->Read(nullptr, wrap->write_size_);
+ // Ensure that the progress will be made and `InvokeQueued` will be called.
+ wrap->ClearIn();
+
// Try writing more data
wrap->write_size_ = 0;
wrap->EncOut();