diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2022-11-27 04:50:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 04:50:14 +0100 |
commit | 0012484f4f194664bea87879ab9f4f20f4ee86c6 (patch) | |
tree | 29feb95f1f41cc68bce5b3cfedb4e04d7c186cb6 /ext/flash/request.rs | |
parent | 95fb4b886b6f8cb0c3805cd77b6c1359e967bd60 (diff) |
Revert "fix(ext/flash): graceful server startup/shutdown with unsettl… (#16839)
…ed promises in mind (#16616)"
This reverts commit fd023cf7937e67dfde5482d34ebc60839eb7397c.
There are reports saying that Vite is often hanging in 1.28.2 and this
is
the only PR that changed something with HTTP server. I think we should
hold off on trying to fix this and instead focus on #16787
CC @magurotuna
Diffstat (limited to 'ext/flash/request.rs')
-rw-r--r-- | ext/flash/request.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/ext/flash/request.rs b/ext/flash/request.rs index ac077df6f..0736b5620 100644 --- a/ext/flash/request.rs +++ b/ext/flash/request.rs @@ -2,7 +2,6 @@ use crate::Stream; use std::pin::Pin; -use tokio::sync::oneshot; #[derive(Debug)] pub struct InnerRequest { @@ -21,7 +20,8 @@ pub struct Request { pub inner: InnerRequest, // Pointer to stream owned by the server loop thread. // - // Dereferencing is safe until websocket upgrade is performed. + // Dereferencing is safe until server thread finishes and + // op_flash_serve resolves or websocket upgrade is performed. pub socket: *mut Stream, pub keep_alive: bool, pub content_read: usize, @@ -29,8 +29,6 @@ pub struct Request { pub remaining_chunk_size: Option<usize>, pub te_chunked: bool, pub expect_continue: bool, - pub socket_rx: oneshot::Receiver<Pin<Box<Stream>>>, - pub owned_socket: Option<Pin<Box<Stream>>>, } // SAFETY: Sent from server thread to JS thread. @@ -39,16 +37,8 @@ unsafe impl Send for Request {} impl Request { #[inline(always)] - pub fn socket<'a>(&mut self) -> &'a mut Stream { - if let Ok(mut sock) = self.socket_rx.try_recv() { - // SAFETY: We never move the data out of the acquired mutable reference. - self.socket = unsafe { sock.as_mut().get_unchecked_mut() }; - - // Let the struct own the socket so that it won't get dropped. - self.owned_socket = Some(sock); - } - - // SAFETY: Dereferencing is safe until server thread detaches socket. + pub fn socket<'a>(&self) -> &'a mut Stream { + // SAFETY: Dereferencing is safe until server thread detaches socket or finishes. unsafe { &mut *self.socket } } |