mirror of
https://github.com/denoland/deno.git
synced 2025-02-12 16:59:32 -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,
|
BadResourcePrototype,
|
||||||
InterruptedPrototype,
|
InterruptedPrototype,
|
||||||
internalRidSymbol,
|
internalRidSymbol,
|
||||||
|
internalFdSymbol,
|
||||||
createCancelHandle,
|
createCancelHandle,
|
||||||
} = core;
|
} = core;
|
||||||
import {
|
import {
|
||||||
|
@ -99,28 +100,26 @@ class Conn {
|
||||||
|
|
||||||
#readable;
|
#readable;
|
||||||
#writable;
|
#writable;
|
||||||
#fd = -1;
|
|
||||||
|
|
||||||
constructor(rid, remoteAddr, localAddr, fd) {
|
constructor(rid, remoteAddr, localAddr, fd) {
|
||||||
ObjectDefineProperty(this, internalRidSymbol, {
|
ObjectDefineProperty(this, internalRidSymbol, {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: rid,
|
value: rid,
|
||||||
});
|
});
|
||||||
|
ObjectDefineProperty(this, internalFdSymbol, {
|
||||||
|
_proto_: null,
|
||||||
|
enumerable: false,
|
||||||
|
value: fd,
|
||||||
|
});
|
||||||
this.#rid = rid;
|
this.#rid = rid;
|
||||||
this.#remoteAddr = remoteAddr;
|
this.#remoteAddr = remoteAddr;
|
||||||
this.#localAddr = localAddr;
|
this.#localAddr = localAddr;
|
||||||
this.#fd = fd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get remoteAddr() {
|
get remoteAddr() {
|
||||||
return this.#remoteAddr;
|
return this.#remoteAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
get fd() {
|
|
||||||
return this.#fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
get localAddr() {
|
get localAddr() {
|
||||||
return this.#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 readable: ReadableStream<Uint8Array>;
|
||||||
readonly writable: WritableStream<Uint8Array>;
|
readonly writable: WritableStream<Uint8Array>;
|
||||||
|
|
||||||
readonly fd: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @category Network */
|
/** @category Network */
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
// deno-lint-ignore-file prefer-primordials
|
// 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 { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { unreachable } from "ext:deno_node/_util/asserts.ts";
|
import { unreachable } from "ext:deno_node/_util/asserts.ts";
|
||||||
import { ConnectionWrap } from "ext:deno_node/internal_binding/connection_wrap.ts";
|
import { ConnectionWrap } from "ext:deno_node/internal_binding/connection_wrap.ts";
|
||||||
|
@ -131,8 +133,8 @@ export class TCP extends ConnectionWrap {
|
||||||
|
|
||||||
super(provider, conn);
|
super(provider, conn);
|
||||||
|
|
||||||
if (conn?.fd) {
|
if (this[kStreamBaseField]) {
|
||||||
this[fdSymbol] = conn.fd;
|
this[fdSymbol] = this[kStreamBaseField][internalFdSymbol];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(cmorten): the handling of new connections and construction feels
|
// TODO(cmorten): the handling of new connections and construction feels
|
||||||
|
|
Loading…
Add table
Reference in a new issue