Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 7de203d

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 15e41a9 as of 2018-02-24 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Seth Brenith <sethb@microsoft.com>
2 parents 95382cc + 15e41a9 commit 7de203d

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ deps/uv/docs/src/guide/
123123

124124
# do not override V8's .gitignore
125125
!deps/v8/**
126+
# ignore VS compiler output unhandled by V8's .gitignore
127+
deps/v8/src/Debug/
128+
deps/v8/src/Release/
129+
deps/v8/src/inspector/Debug/
130+
deps/v8/src/inspector/Release/

src/tls_wrap.cc

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,12 @@ void TLSWrap::EncOut() {
298298

299299

300300
void TLSWrap::OnStreamAfterWrite(WriteWrap* req_wrap, int status) {
301-
// Report back to the previous listener as well. This is only needed for the
302-
// "empty" writes that are passed through directly to the underlying stream.
303-
if (req_wrap != nullptr)
304-
previous_listener_->OnStreamAfterWrite(req_wrap, status);
301+
if (current_empty_write_ != nullptr) {
302+
WriteWrap* finishing = current_empty_write_;
303+
current_empty_write_ = nullptr;
304+
finishing->Done(status);
305+
return;
306+
}
305307

306308
if (ssl_ == nullptr)
307309
status = UV_ECANCELED;
@@ -567,18 +569,17 @@ int TLSWrap::DoWrite(WriteWrap* w,
567569
// However, if there is any data that should be written to the socket,
568570
// the callback should not be invoked immediately
569571
if (BIO_pending(enc_out_) == 0) {
570-
// We destroy the current WriteWrap* object and create a new one that
571-
// matches the underlying stream, rather than the TLSWrap itself.
572-
573-
// Note: We cannot simply use w->object() because of the "optimized"
574-
// way in which we read persistent handles; the JS object itself might be
575-
// destroyed by w->Dispose(), and the Local<Object> we have is not a
576-
// "real" handle in the sense the V8 is aware of its existence.
577-
Local<Object> req_wrap_obj =
578-
w->GetAsyncWrap()->persistent().Get(env()->isolate());
579-
w->Dispose();
580-
w = underlying_stream()->CreateWriteWrap(req_wrap_obj);
581-
return stream_->DoWrite(w, bufs, count, send_handle);
572+
CHECK_EQ(current_empty_write_, nullptr);
573+
current_empty_write_ = w;
574+
StreamWriteResult res =
575+
underlying_stream()->Write(bufs, count, send_handle);
576+
if (!res.async) {
577+
env()->SetImmediate([](Environment* env, void* data) {
578+
TLSWrap* self = static_cast<TLSWrap*>(data);
579+
self->OnStreamAfterWrite(self->current_empty_write_, 0);
580+
}, this, object());
581+
}
582+
return 0;
582583
}
583584
}
584585

src/tls_wrap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class TLSWrap : public AsyncWrap,
152152
std::vector<uv_buf_t> pending_cleartext_input_;
153153
size_t write_size_;
154154
WriteWrap* current_write_ = nullptr;
155+
WriteWrap* current_empty_write_ = nullptr;
155156
bool write_callback_scheduled_ = false;
156157
bool started_;
157158
bool established_;

0 commit comments

Comments
 (0)