http2: refactor close/destroy for Http2Stream and Http2Session
This is a significant refactoring of the close/destroy flow and API for Http2Stream
and Http2Session
. There is quite a bit more to do in here, it's a bit slow going because the flow is rather complex and I'm trying not to break too much as I go.
There are several important bits:
-
Previously, the destroy operations for both
Http2Session
andHttp2Stream
were executed over multiple nextTick and setImmediate hops. Now the objects are unusable immediately when callingdestroy()
and we're usingenv->SetImmediate()
to handle the need to defer final cleanup (cc @addaleax) -
This reworks the destroy and error handling flow between the
Http2Session
and socket and eliminates the'socketError'
event. Errors occurring on the socket are forwarded to the error event on the associatedHttp2Session
. On the server, those are forwarded to the'sessionError'
event. -
Http2Stream.prototype.rstStream()
has been renamed toHttp2Stream.prototype.close()
and the variousrstWith....
aliases have been removed. -
An improved
Http2Session.prototype.close()
has been implemented, allowing better API symmetry.
There are still a few more todo's that need to be handled here. Specifically, proper handling of last stream ID on a goaway frame, but this is already a sizable chunk of work. Let's get this reviewed and landed and I'll keep pushing forward.
/cc @nodejs/http2
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
http2