fix(ext/flash): graceful server startup/shutdown with unsettled promises in mind (#16616)

This PR resets the revert commit made by #16610, bringing back #16383
which attempts to fix the issue happening when we use the flash server
with `--watch` option enabled.
Also, some code changes are made to pass the regression test added in
#16610.
This commit is contained in:
Yusuke Tanaka 2022-11-25 02:38:09 +09:00 committed by GitHub
parent b6f49cf479
commit fd023cf793
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 305 additions and 148 deletions

View file

@ -1,23 +1,26 @@
use deno_core::error::AnyError;
use mio::net::TcpStream;
use std::{
cell::UnsafeCell,
future::Future,
io::{Read, Write},
pin::Pin,
sync::{Arc, Mutex},
};
use std::cell::UnsafeCell;
use std::future::Future;
use std::io::Read;
use std::io::Write;
use std::marker::PhantomPinned;
use std::pin::Pin;
use std::sync::Arc;
use std::sync::Mutex;
use tokio::sync::mpsc;
use crate::ParseStatus;
type TlsTcpStream = rustls::StreamOwned<rustls::ServerConnection, TcpStream>;
#[derive(Debug)]
pub enum InnerStream {
Tcp(TcpStream),
Tls(Box<TlsTcpStream>),
}
#[derive(Debug)]
pub struct Stream {
pub inner: InnerStream,
pub detached: bool,
@ -26,6 +29,7 @@ pub struct Stream {
pub parse_done: ParseStatus,
pub buffer: UnsafeCell<Vec<u8>>,
pub read_lock: Arc<Mutex<()>>,
pub _pinned: PhantomPinned,
}
impl Stream {