Skip to content

Commit

Permalink
src: remove kFlagNoShutdown flag
Browse files Browse the repository at this point in the history
This was originally introduced in 3446ff4, in order to fix
a hard crash. However, since the libuv 1.18.0 update, that hard
crash is gone, and since f2b9805 we do not throw an
error in JS land anymore either, rendering the flag unnecessary.

Also, the original test that checked this condition was added
to `test/parallel/`. Since that typically runs without a TTY stdin,
a duplicate test is being added to the pseudo-tty test suite
in this commit.

Refs: 3446ff4
Refs: f2b9805
Refs: libuv/libuv@0e28141
  • Loading branch information
addaleax committed Apr 28, 2018
1 parent b55a11d commit 90f2f07
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/stream_base-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ void StreamBase::AddMethods(Environment* env,

env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStartJS>);
env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStopJS>);
if ((flags & kFlagNoShutdown) == 0)
env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>);
env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>);
if ((flags & kFlagHasWritev) != 0)
env->SetProtoMethod(t, "writev", JSMethod<Base, &StreamBase::Writev>);
env->SetProtoMethod(t,
Expand Down
3 changes: 1 addition & 2 deletions src/stream_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ class StreamBase : public StreamResource {
public:
enum Flags {
kFlagNone = 0x0,
kFlagHasWritev = 0x1,
kFlagNoShutdown = 0x2
kFlagHasWritev = 0x1
};

template <class Base>
Expand Down
2 changes: 1 addition & 1 deletion src/tty_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void TTYWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "ref", HandleWrap::Ref);
env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef);

LibuvStreamWrap::AddMethods(env, t, StreamBase::kFlagNoShutdown);
LibuvStreamWrap::AddMethods(env, t);

env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize);
env->SetProtoMethod(t, "setRawMode", SetRawMode);
Expand Down
7 changes: 7 additions & 0 deletions test/pseudo-tty/test-tty-stdin-end.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';
require('../common');

// This test ensures that Node.js doesn't crash on `process.stdin.emit("end")`.
// https://github.com/nodejs/node/issues/1068

process.stdin.emit('end');
1 change: 1 addition & 0 deletions test/pseudo-tty/test-tty-stdin-end.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 90f2f07

Please sign in to comment.