| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5ad9929 commit 9398d84
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -386,13 +386,11 @@ function connectionListenerInternal(server, socket) { | |||
| 386 | 386 | socket.on = socketOnWrap; | |
| 387 | 387 | ||
| 388 | 388 | // We only consume the socket if it has never been consumed before. | |
| 389 | - if (socket._handle) { | ||
| 390 | - var external = socket._handle._externalStream; | ||
| 391 | - if (!socket._handle._consumed && external) { | ||
| 392 | - parser._consumed = true; | ||
| 393 | - socket._handle._consumed = true; | ||
| 394 | - parser.consume(external); | ||
| 395 | - } | ||
| 389 | + if (socket._handle && socket._handle.isStreamBase && | ||
| 390 | + !socket._handle._consumed) { | ||
| 391 | + parser._consumed = true; | ||
| 392 | + socket._handle._consumed = true; | ||
| 393 | + parser.consume(socket._handle); | ||
| 396 | 394 | } | |
| 397 | 395 | parser[kOnExecute] = | |
| 398 | 396 | onParserExecute.bind(undefined, server, socket, parser, state); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -441,14 +441,10 @@ TLSSocket.prototype._wrapHandle = function(wrap) { | |||
| 441 | 441 | const context = options.secureContext || | |
| 442 | 442 | options.credentials || | |
| 443 | 443 | tls.createSecureContext(options); | |
| 444 | - const externalStream = handle._externalStream; | ||
| 445 | - assert(typeof externalStream === 'object', | ||
| 446 | - 'handle must be a LibuvStreamWrap'); | ||
| 444 | + assert(handle.isStreamBase, 'handle must be a StreamBase'); | ||
| 447 | 445 | assert(context.context instanceof NativeSecureContext, | |
| 448 | 446 | 'context.context must be a NativeSecureContext'); | |
| 449 | - const res = tls_wrap.wrap(externalStream, | ||
| 450 | - context.context, | ||
| 451 | - !!options.isServer); | ||
| 447 | + const res = tls_wrap.wrap(handle, context.context, !!options.isServer); | ||
| 452 | 448 | res._parent = handle; // C++ "wrap" object: TCPWrap, JSStream, ... | |
| 453 | 449 | res._parentWrap = wrap; // JS object: net.Socket, JSStreamSocket, ... | |
| 454 | 450 | res._secureContext = context; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -847,7 +847,7 @@ function setupHandle(socket, type, options) { | |||
| 847 | 847 | ||
| 848 | 848 | if (typeof options.selectPadding === 'function') | |
| 849 | 849 | this[kSelectPadding] = options.selectPadding; | |
| 850 | - handle.consume(socket._handle._externalStream); | ||
| 850 | + handle.consume(socket._handle); | ||
| 851 | 851 | ||
| 852 | 852 | this[kHandle] = handle; | |
| 853 | 853 | ||
@@ -937,7 +937,7 @@ class Http2Session extends EventEmitter { | |||
| 937 | 937 | constructor(type, options, socket) { | |
| 938 | 938 | super(); | |
| 939 | 939 | ||
| 940 | - if (!socket._handle || !socket._handle._externalStream) { | ||
| 940 | + if (!socket._handle || !socket._handle.isStreamBase) { | ||
| 941 | 941 | socket = new JSStreamSocket(socket); | |
| 942 | 942 | } | |
| 943 | 943 | ||
@@ -2097,8 +2097,7 @@ function startFilePipe(self, fd, offset, length) { | |||
| 2097 | 2097 | handle.onread = onPipedFileHandleRead; | |
| 2098 | 2098 | handle.stream = self; | |
| 2099 | 2099 | ||
| 2100 | - const pipe = new StreamPipe(handle._externalStream, | ||
| 2101 | - self[kHandle]._externalStream); | ||
| 2100 | + const pipe = new StreamPipe(handle, self[kHandle]); | ||
| 2102 | 2101 | pipe.onunpipe = onFileUnpipe; | |
| 2103 | 2102 | pipe.start(); | |
| 2104 | 2103 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1837,8 +1837,8 @@ bool Http2Session::HasWritesOnSocketForStream(Http2Stream* stream) { | |||
| 1837 | 1837 | // (typically a net.Socket or tls.TLSSocket). The lifecycle of the two is | |
| 1838 | 1838 | // tightly coupled with all data transfer between the two happening at the | |
| 1839 | 1839 | // C++ layer via the StreamBase API. | |
| 1840 | - void Http2Session::Consume(Local<External> external) { | ||
| 1841 | - StreamBase* stream = static_cast<StreamBase*>(external->Value()); | ||
| 1840 | + void Http2Session::Consume(Local<Object> stream_obj) { | ||
| 1841 | + StreamBase* stream = StreamBase::FromObject(stream_obj); | ||
| 1842 | 1842 | stream->PushStreamListener(this); | |
| 1843 | 1843 | Debug(this, "i/o stream consumed"); | |
| 1844 | 1844 | } | |
@@ -2429,8 +2429,8 @@ void Http2Session::New(const FunctionCallbackInfo<Value>& args) { | |||
| 2429 | 2429 | void Http2Session::Consume(const FunctionCallbackInfo<Value>& args) { | |
| 2430 | 2430 | Http2Session* session; | |
| 2431 | 2431 | ASSIGN_OR_RETURN_UNWRAP(&session, args.Holder()); | |
| 2432 | - CHECK(args[0]->IsExternal()); | ||
| 2433 | - session->Consume(args[0].As<External>()); | ||
| 2432 | + CHECK(args[0]->IsObject()); | ||
| 2433 | + session->Consume(args[0].As<Object>()); | ||
| 2434 | 2434 | } | |
| 2435 | 2435 | ||
| 2436 | 2436 | // Destroys the Http2Session instance and renders it unusable | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -696,7 +696,7 @@ class Http2Session : public AsyncWrap, public StreamListener { | |||
| 696 | 696 | ||
| 697 | 697 | void Close(uint32_t code = NGHTTP2_NO_ERROR, | |
| 698 | 698 | bool socket_closed = false); | |
| 699 | - void Consume(Local<External> external); | ||
| 699 | + void Consume(Local<Object> stream); | ||
| 700 | 700 | void Goaway(uint32_t code, int32_t lastStreamID, | |
| 701 | 701 | const uint8_t* data, size_t len); | |
| 702 | 702 | void AltSvc(int32_t id, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -556,9 +556,8 @@ class Parser : public AsyncWrap, public StreamListener { | |||
| 556 | 556 | static void Consume(const FunctionCallbackInfo<Value>& args) { | |
| 557 | 557 | Parser* parser; | |
| 558 | 558 | ASSIGN_OR_RETURN_UNWRAP(&parser, args.Holder()); | |
| 559 | - CHECK(args[0]->IsExternal()); | ||
| 560 | - Local<External> stream_obj = args[0].As<External>(); | ||
| 561 | - StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value()); | ||
| 559 | + CHECK(args[0]->IsObject()); | ||
| 560 | + StreamBase* stream = StreamBase::FromObject(args[0].As<Object>()); | ||
| 562 | 561 | CHECK_NOT_NULL(stream); | |
| 563 | 562 | stream->PushStreamListener(parser); | |
| 564 | 563 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,6 @@ | |||
| 12 | 12 | namespace node { | |
| 13 | 13 | ||
| 14 | 14 | using v8::Signature; | |
| 15 | - using v8::External; | ||
| 16 | 15 | using v8::FunctionCallbackInfo; | |
| 17 | 16 | using v8::FunctionTemplate; | |
| 18 | 17 | using v8::HandleScope; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,7 @@ namespace node { | |||
| 17 | 17 | using v8::Array; | |
| 18 | 18 | using v8::ArrayBuffer; | |
| 19 | 19 | using v8::Context; | |
| 20 | + using v8::External; | ||
| 20 | 21 | using v8::FunctionCallbackInfo; | |
| 21 | 22 | using v8::HandleScope; | |
| 22 | 23 | using v8::Integer; | |
@@ -368,6 +369,9 @@ void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) { | |||
| 368 | 369 | t, "writeUcs2String", JSMethod<&StreamBase::WriteString<UCS2>>); | |
| 369 | 370 | env->SetProtoMethod( | |
| 370 | 371 | t, "writeLatin1String", JSMethod<&StreamBase::WriteString<LATIN1>>); | |
| 372 | + t->PrototypeTemplate()->Set(FIXED_ONE_BYTE_STRING(env->isolate(), | ||
| 373 | + "isStreamBase"), | ||
| 374 | + True(env->isolate())); | ||
| 371 | 375 | } | |
| 372 | 376 | ||
| 373 | 377 | void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ | |||
| 3 | 3 | #include "node_buffer.h" | |
| 4 | 4 | ||
| 5 | 5 | using v8::Context; | |
| 6 | - using v8::External; | ||
| 7 | 6 | using v8::Function; | |
| 8 | 7 | using v8::FunctionCallbackInfo; | |
| 9 | 8 | using v8::FunctionTemplate; | |
@@ -226,10 +225,10 @@ void StreamPipe::WritableListener::OnStreamRead(ssize_t nread, | |||
| 226 | 225 | ||
| 227 | 226 | void StreamPipe::New(const FunctionCallbackInfo<Value>& args) { | |
| 228 | 227 | CHECK(args.IsConstructCall()); | |
| 229 | - CHECK(args[0]->IsExternal()); | ||
| 230 | - CHECK(args[1]->IsExternal()); | ||
| 231 | - auto source = static_cast<StreamBase*>(args[0].As<External>()->Value()); | ||
| 232 | - auto sink = static_cast<StreamBase*>(args[1].As<External>()->Value()); | ||
| 228 | + CHECK(args[0]->IsObject()); | ||
| 229 | + CHECK(args[1]->IsObject()); | ||
| 230 | + StreamBase* source = StreamBase::FromObject(args[0].As<Object>()); | ||
| 231 | + StreamBase* sink = StreamBase::FromObject(args[1].As<Object>()); | ||
| 233 | 232 | ||
| 234 | 233 | new StreamPipe(source, sink, args.This()); | |
| 235 | 234 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -150,12 +150,11 @@ void TLSWrap::Wrap(const FunctionCallbackInfo<Value>& args) { | |||
| 150 | 150 | CHECK(args[1]->IsObject()); | |
| 151 | 151 | CHECK(args[2]->IsBoolean()); | |
| 152 | 152 | ||
| 153 | - Local<External> stream_obj = args[0].As<External>(); | ||
| 154 | 153 | Local<Object> sc = args[1].As<Object>(); | |
| 155 | 154 | Kind kind = args[2]->IsTrue() ? SSLWrap<TLSWrap>::kServer : | |
| 156 | 155 | SSLWrap<TLSWrap>::kClient; | |
| 157 | 156 | ||
| 158 | - StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value()); | ||
| 157 | + StreamBase* stream = StreamBase::FromObject(args[0].As<Object>()); | ||
| 159 | 158 | CHECK_NOT_NULL(stream); | |
| 160 | 159 | ||
| 161 | 160 | Local<Object> obj; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments