diff options
author | Denys Otrishko <shishugi@gmail.com> | 2019-12-07 20:04:12 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-25 13:07:02 +0300 |
commit | a8c2c667ce896f3b168e8622eefa878b355d7c9a (patch) | |
tree | d1f7f7dd886670ee73e6c5e54ce9fe51c95c3d93 /src | |
parent | 398790149d18a26dd4b9ec263214345467d7439e (diff) |
http2: wait for session to finish writing before destroy
PR-URL: https://github.com/nodejs/node/pull/30854
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_http2.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc index db3bd035b34..b8d93171329 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -700,6 +700,13 @@ void Http2Session::Close(uint32_t code, bool socket_closed) { flags_ |= SESSION_STATE_CLOSED; + // If we are writing we will get to make the callback in OnStreamAfterWrite. + if ((flags_ & SESSION_STATE_WRITE_IN_PROGRESS) == 0) { + Debug(this, "make done session callback"); + HandleScope scope(env()->isolate()); + MakeCallback(env()->ondone_string(), 0, nullptr); + } + // If there are outstanding pings, those will need to be canceled, do // so on the next iteration of the event loop to avoid calling out into // javascript since this may be called during garbage collection. @@ -1502,6 +1509,12 @@ void Http2Session::OnStreamAfterWrite(WriteWrap* w, int status) { stream_->ReadStart(); } + if ((flags_ & SESSION_STATE_CLOSED) != 0) { + HandleScope scope(env()->isolate()); + MakeCallback(env()->ondone_string(), 0, nullptr); + return; + } + // If there is more incoming data queued up, consume it. if (stream_buf_offset_ > 0) { ConsumeHTTP2Data(); |