-
Notifications
You must be signed in to change notification settings - Fork 7.3k
stream_wrap: Fix issue with null file handles #25535
Conversation
@trevnorris @cjihrig ... can either of you take a quick look at this as well? |
@mhdawson @dnakamura ... we'd likely want to target this PR against v0.12 rather than master. |
@@ -224,6 +224,10 @@ void StreamWrap::WriteBuffer(const FunctionCallbackInfo<Value>& args) { | |||
Environment* env = Environment::GetCurrent(args.GetIsolate()); | |||
|
|||
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder()); | |||
if ( NULL == wrap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the space between (
and NULL
in all of your if
statements. I think core normally writes as wrap == NULL
as well.
In putting together a test case we discovered a few other problems as well. Devin is working on capturing the test cases and looking at alternate changes to see if what was in the pull request still makes sense or something higher up would make more sense |
I gave some explanation to the underlying problem in #25365. Code for reproducing, which is run in the root directory of https://github.com/EricSmekens/testNodeJS (which is just used for server certs) client:
server:
Also note that closing the secure socket after closing the normal socket results in unexpected behaviour.
gives the output:
Changing the order (closing the secure socket before the regular socket) results in the close event on the secure socket being emitted twice |
Fixes #25365. Essentially, a file I/O request is generated and queued, in a different thread the stream is closed and handle set to null. When a worker thread then tries to execute the request it gets a null handle