diff options
author | Denys Otrishko <shishugi@gmail.com> | 2019-12-07 20:04:12 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-01-03 18:12:14 +0300 |
commit | 86f2e869dcc287d44185b64881a1b6e07a55a872 (patch) | |
tree | ff767895cbd56e7cfe8d4cbc5a1c54ba3df8314f /src/node_http2.cc | |
parent | 69d6e9732b4dabbe9766300ecb996e3d9d6beba9 (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/node_http2.cc')
-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 760533b6054..b58505f10c9 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -683,6 +683,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. @@ -1485,6 +1492,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(); |