mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
use internal symbol to read fd
This commit is contained in:
parent
b1eb1f66bf
commit
9609ed39c3
3 changed files with 10 additions and 11 deletions
|
@ -5,6 +5,7 @@ const {
|
|||
BadResourcePrototype,
|
||||
InterruptedPrototype,
|
||||
internalRidSymbol,
|
||||
internalFdSymbol,
|
||||
createCancelHandle,
|
||||
} = core;
|
||||
import {
|
||||
|
@ -99,28 +100,26 @@ class Conn {
|
|||
|
||||
#readable;
|
||||
#writable;
|
||||
#fd = -1;
|
||||
|
||||
constructor(rid, remoteAddr, localAddr, fd) {
|
||||
ObjectDefineProperty(this, internalRidSymbol, {
|
||||
__proto__: null,
|
||||
enumerable: false,
|
||||
value: rid,
|
||||
});
|
||||
ObjectDefineProperty(this, internalFdSymbol, {
|
||||
_proto_: null,
|
||||
enumerable: false,
|
||||
value: fd,
|
||||
});
|
||||
this.#rid = rid;
|
||||
this.#remoteAddr = remoteAddr;
|
||||
this.#localAddr = localAddr;
|
||||
this.#fd = fd;
|
||||
}
|
||||
|
||||
get remoteAddr() {
|
||||
return this.#remoteAddr;
|
||||
}
|
||||
|
||||
get fd() {
|
||||
return this.#fd;
|
||||
}
|
||||
|
||||
get localAddr() {
|
||||
return this.#localAddr;
|
||||
}
|
||||
|
|
2
ext/net/lib.deno_net.d.ts
vendored
2
ext/net/lib.deno_net.d.ts
vendored
|
@ -138,8 +138,6 @@ declare namespace Deno {
|
|||
|
||||
readonly readable: ReadableStream<Uint8Array>;
|
||||
readonly writable: WritableStream<Uint8Array>;
|
||||
|
||||
readonly fd: number;
|
||||
}
|
||||
|
||||
/** @category Network */
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||
// deno-lint-ignore-file prefer-primordials
|
||||
|
||||
import { core } from "ext:core/mod.js";
|
||||
const { internalFdSymbol } = core;
|
||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||
import { unreachable } from "ext:deno_node/_util/asserts.ts";
|
||||
import { ConnectionWrap } from "ext:deno_node/internal_binding/connection_wrap.ts";
|
||||
|
@ -131,8 +133,8 @@ export class TCP extends ConnectionWrap {
|
|||
|
||||
super(provider, conn);
|
||||
|
||||
if (conn?.fd) {
|
||||
this[fdSymbol] = conn.fd;
|
||||
if (this[kStreamBaseField]) {
|
||||
this[fdSymbol] = this[kStreamBaseField][internalFdSymbol];
|
||||
}
|
||||
|
||||
// TODO(cmorten): the handling of new connections and construction feels
|
||||
|
|
Loading…
Add table
Reference in a new issue