mirror of
https://github.com/denoland/deno.git
synced 2025-01-05 13:59:01 -05:00
wip
This commit is contained in:
parent
95ad0faddb
commit
f9c1219f7c
8 changed files with 26 additions and 5 deletions
|
@ -100,10 +100,12 @@ impl Resource for TcpStreamResource {
|
|||
}
|
||||
|
||||
fn shutdown(self: Rc<Self>) -> AsyncResult<()> {
|
||||
eprintln!("shutdown TcpStreamResource");
|
||||
Box::pin(self.shutdown())
|
||||
}
|
||||
|
||||
fn close(self: Rc<Self>) {
|
||||
eprintln!("close TcpStreamResource");
|
||||
self.cancel_read_ops();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,6 +328,7 @@ where
|
|||
let rid = state_
|
||||
.resource_table
|
||||
.add(TcpStreamResource::new(tcp_stream.into_split()));
|
||||
eprintln!("adding TcpStreamResource in op_net_connect_tcp: {rid}");
|
||||
|
||||
Ok((rid, IpAddr::from(local_addr), IpAddr::from(remote_addr)))
|
||||
}
|
||||
|
@ -654,6 +655,7 @@ pub fn op_set_nodelay_inner(
|
|||
) -> Result<(), AnyError> {
|
||||
let resource: Rc<TcpStreamResource> =
|
||||
state.resource_table.get::<TcpStreamResource>(rid)?;
|
||||
println!("setting nodelay (rid: {rid}): {nodelay}");
|
||||
resource.set_nodelay(nodelay)
|
||||
}
|
||||
|
||||
|
@ -674,6 +676,7 @@ pub fn op_set_keepalive_inner(
|
|||
) -> Result<(), AnyError> {
|
||||
let resource: Rc<TcpStreamResource> =
|
||||
state.resource_table.get::<TcpStreamResource>(rid)?;
|
||||
eprintln!("setting keepalive (rid: {rid}): {keepalive}");
|
||||
resource.set_keepalive(keepalive)
|
||||
}
|
||||
|
||||
|
|
|
@ -293,6 +293,7 @@ where
|
|||
.borrow::<DefaultTlsOptions>()
|
||||
.root_cert_store()?;
|
||||
|
||||
println!("used in op_tls_start");
|
||||
let resource_rc = state
|
||||
.borrow_mut()
|
||||
.resource_table
|
||||
|
|
|
@ -329,7 +329,7 @@ pub fn take_network_stream_resource(
|
|||
// The stream we're attempting to unwrap may be in use somewhere else. If that's the case, we cannot proceed
|
||||
// with the process of unwrapping this connection, so we just return a bad resource error.
|
||||
// See also: https://github.com/denoland/deno/pull/16242
|
||||
|
||||
println!("used in take_network_stream_resource");
|
||||
if let Ok(resource_rc) = resource_table.take::<TcpStreamResource>(stream_rid)
|
||||
{
|
||||
// This TCP connection might be used somewhere else.
|
||||
|
|
|
@ -107,8 +107,15 @@ where
|
|||
.borrow_mut()
|
||||
.resource_table
|
||||
.take::<TcpStreamResource>(conn_rid)?;
|
||||
let resource = Rc::try_unwrap(resource_rc)
|
||||
.map_err(|_| bad_resource("TCP stream is currently in use"))?;
|
||||
eprintln!(
|
||||
"rc: strong_count: {strong_count} weak_count: {weak_count}",
|
||||
strong_count = Rc::strong_count(&resource_rc),
|
||||
weak_count = Rc::weak_count(&resource_rc)
|
||||
);
|
||||
let resource = Rc::try_unwrap(resource_rc).map_err(|e| {
|
||||
eprintln!("error: {:?}", e);
|
||||
bad_resource("TCP stream is currently in use")
|
||||
})?;
|
||||
let (read_half, write_half) = resource.into_inner();
|
||||
let tcp_stream = read_half.reunite(write_half)?;
|
||||
let io = TokioIo::new(tcp_stream);
|
||||
|
|
|
@ -524,7 +524,7 @@ Object.defineProperties(
|
|||
_send(data: any, encoding?: string | null, callback?: () => void) {
|
||||
// if socket is ready, write the data after headers are written.
|
||||
// if socket is not ready, buffer data in outputbuffer.
|
||||
if (this.socket) {
|
||||
if (this.socket && !this.socket.connecting) {
|
||||
console.log("im never invoked");
|
||||
if (!this._headerSent && this._header !== null) {
|
||||
this._writeHeader();
|
||||
|
|
|
@ -640,13 +640,20 @@ class ClientRequest extends OutgoingMessage {
|
|||
if (chunk) {
|
||||
this.write_(chunk, encoding, null, true);
|
||||
} else if (!this._headerSent) {
|
||||
if (this.socket) {
|
||||
if (this.socket && !this.socket.connecting) {
|
||||
this._contentLength = 0;
|
||||
console.log(
|
||||
"end: _implicitHeader; socket.rid",
|
||||
this.socket.rid,
|
||||
"socket.connecting",
|
||||
this.socket.connecting,
|
||||
);
|
||||
this._implicitHeader();
|
||||
this._send("", "latin1");
|
||||
} else {
|
||||
this.on("socket", (socket) => {
|
||||
socket.on("connect", () => {
|
||||
console.log("connect emitted - sending implicit header");
|
||||
this._contentLength = 0;
|
||||
this._implicitHeader();
|
||||
this._send("", "latin1");
|
||||
|
|
|
@ -22,6 +22,7 @@ fn op_http_start(
|
|||
state: &mut OpState,
|
||||
#[smi] tcp_stream_rid: ResourceId,
|
||||
) -> Result<ResourceId, AnyError> {
|
||||
println!("used in op_http_start");
|
||||
if let Ok(resource_rc) = state
|
||||
.resource_table
|
||||
.take::<TcpStreamResource>(tcp_stream_rid)
|
||||
|
|
Loading…
Reference in a new issue