mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
smol: Use Unblock instead of Async for stdin, stdout and stderr handles (#46141)
as per its documentation: `Async` supports all networking types, as well as some OS-specific file descriptors like timerfd and inotify. However, do not use `Async` with types like File, Stdin, Stdout, or Stderr because all operating systems have issues with them when put in non-blocking mode. Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
parent
c7c0f560b8
commit
797276bc73
2 changed files with 7 additions and 7 deletions
|
|
@ -16,15 +16,15 @@ pub fn main(_socket: &str) -> Result<()> {
|
|||
pub fn main(socket: &str) -> Result<()> {
|
||||
use futures::{AsyncReadExt as _, AsyncWriteExt as _, FutureExt as _, io::BufReader, select};
|
||||
use net::async_net::UnixStream;
|
||||
use smol::{Async, io::AsyncBufReadExt};
|
||||
use smol::{Unblock, io::AsyncBufReadExt};
|
||||
|
||||
smol::block_on(async {
|
||||
let socket_stream = UnixStream::connect(socket).await?;
|
||||
let (socket_read, mut socket_write) = socket_stream.split();
|
||||
let mut socket_reader = BufReader::new(socket_read);
|
||||
|
||||
let mut stdout = Async::new(std::io::stdout())?;
|
||||
let stdin = Async::new(std::io::stdin())?;
|
||||
let mut stdout = Unblock::new(std::io::stdout());
|
||||
let stdin = Unblock::new(std::io::stdin());
|
||||
let mut stdin_reader = BufReader::new(stdin);
|
||||
|
||||
let mut socket_line = Vec::new();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use reqwest_client::ReqwestClient;
|
|||
use rpc::proto::{self, Envelope, REMOTE_SERVER_PROJECT_ID};
|
||||
use rpc::{AnyProtoClient, TypedEnvelope};
|
||||
use settings::{Settings, SettingsStore, watch_config_file};
|
||||
use smol::Async;
|
||||
|
||||
use smol::channel::{Receiver, Sender};
|
||||
use smol::io::AsyncReadExt;
|
||||
use smol::{net::unix::UnixListener, stream::StreamExt as _};
|
||||
|
|
@ -627,19 +627,19 @@ pub(crate) fn execute_proxy(
|
|||
})?;
|
||||
|
||||
let stdin_task = smol::spawn(async move {
|
||||
let stdin = Async::new(std::io::stdin())?;
|
||||
let stdin = smol::Unblock::new(std::io::stdin());
|
||||
let stream = smol::net::unix::UnixStream::connect(&server_paths.stdin_socket).await?;
|
||||
handle_io(stdin, stream, "stdin").await
|
||||
});
|
||||
|
||||
let stdout_task: smol::Task<Result<()>> = smol::spawn(async move {
|
||||
let stdout = Async::new(std::io::stdout())?;
|
||||
let stdout = smol::Unblock::new(std::io::stdout());
|
||||
let stream = smol::net::unix::UnixStream::connect(&server_paths.stdout_socket).await?;
|
||||
handle_io(stream, stdout, "stdout").await
|
||||
});
|
||||
|
||||
let stderr_task: smol::Task<Result<()>> = smol::spawn(async move {
|
||||
let mut stderr = Async::new(std::io::stderr())?;
|
||||
let mut stderr = smol::Unblock::new(std::io::stderr());
|
||||
let mut stream = smol::net::unix::UnixStream::connect(&server_paths.stderr_socket).await?;
|
||||
let mut stderr_buffer = vec![0; 2048];
|
||||
loop {
|
||||
|
|
|
|||
Loading…
Reference in a new issue