summaryrefslogtreecommitdiff
path: root/src/tls_wrap.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tls_wrap.cc')
-rw-r--r--src/tls_wrap.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc
index 42b9469e38..4ec6dda6df 100644
--- a/src/tls_wrap.cc
+++ b/src/tls_wrap.cc
@@ -316,9 +316,10 @@ void TLSWrap::EncOut() {
// its not clear if it is always correct. Not calling Done() could block
// data flow, so for now continue to call Done(), just do it in the next
// tick.
- env()->SetImmediate([this](Environment* env) {
+ BaseObjectPtr<TLSWrap> strong_ref{this};
+ env()->SetImmediate([this, strong_ref](Environment* env) {
InvokeQueued(0);
- }, object());
+ });
}
}
return;
@@ -349,9 +350,10 @@ void TLSWrap::EncOut() {
HandleScope handle_scope(env()->isolate());
// Simulate asynchronous finishing, TLS cannot handle this at the moment.
- env()->SetImmediate([this](Environment* env) {
+ BaseObjectPtr<TLSWrap> strong_ref{this};
+ env()->SetImmediate([this, strong_ref](Environment* env) {
OnStreamAfterWrite(nullptr, 0);
- }, object());
+ });
}
}
@@ -718,9 +720,10 @@ int TLSWrap::DoWrite(WriteWrap* w,
StreamWriteResult res =
underlying_stream()->Write(bufs, count, send_handle);
if (!res.async) {
- env()->SetImmediate([this](Environment* env) {
+ BaseObjectPtr<TLSWrap> strong_ref{this};
+ env()->SetImmediate([this, strong_ref](Environment* env) {
OnStreamAfterWrite(current_empty_write_, 0);
- }, object());
+ });
}
return 0;
}