Browse Source

tty: do not add `shutdown` method to handle

UV_TTY does not support `uv_shutdown()` so adding this method in
StreamBase will cause an `abort()` in C land.

Fix: https://github.com/iojs/io.js/issues/1068
PR-URL: https://github.com/iojs/io.js/pull/1073
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v1.8.0-commit
Fedor Indutny 10 years ago
parent
commit
3446ff417b
  1. 3
      src/stream_base-inl.h
  2. 3
      src/stream_base.h
  3. 2
      src/tty_wrap.cc
  4. 1
      test/parallel/test-regress-GH-io-1068.js

3
src/stream_base-inl.h

@ -37,7 +37,8 @@ void StreamBase::AddMethods(Environment* env,
env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStart>); env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStart>);
env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStop>); env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStop>);
env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>); if ((flags & kFlagNoShutdown) == 0)
env->SetProtoMethod(t, "shutdown", JSMethod<Base, &StreamBase::Shutdown>);
if ((flags & kFlagHasWritev) != 0) if ((flags & kFlagHasWritev) != 0)
env->SetProtoMethod(t, "writev", JSMethod<Base, &StreamBase::Writev>); env->SetProtoMethod(t, "writev", JSMethod<Base, &StreamBase::Writev>);
env->SetProtoMethod(t, env->SetProtoMethod(t,

3
src/stream_base.h

@ -160,7 +160,8 @@ class StreamBase : public StreamResource {
public: public:
enum Flags { enum Flags {
kFlagNone = 0x0, kFlagNone = 0x0,
kFlagHasWritev = 0x1 kFlagHasWritev = 0x1,
kFlagNoShutdown = 0x2
}; };
template <class Base> template <class Base>

2
src/tty_wrap.cc

@ -39,7 +39,7 @@ void TTYWrap::Initialize(Handle<Object> target,
env->SetProtoMethod(t, "close", HandleWrap::Close); env->SetProtoMethod(t, "close", HandleWrap::Close);
env->SetProtoMethod(t, "unref", HandleWrap::Unref); env->SetProtoMethod(t, "unref", HandleWrap::Unref);
StreamWrap::AddMethods(env, t); StreamWrap::AddMethods(env, t, StreamBase::kFlagNoShutdown);
env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize); env->SetProtoMethod(t, "getWindowSize", TTYWrap::GetWindowSize);
env->SetProtoMethod(t, "setRawMode", SetRawMode); env->SetProtoMethod(t, "setRawMode", SetRawMode);

1
test/parallel/test-regress-GH-io-1068.js

@ -0,0 +1 @@
process.stdin.emit('end');
Loading…
Cancel
Save