Fixed clean shutdown
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -140,7 +140,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gemserv"
|
||||
version = "0.4.6"
|
||||
version = "0.4.7"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"log",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gemserv"
|
||||
version = "0.4.6"
|
||||
version = "0.4.7"
|
||||
authors = ["int 80h <int@80h.dev>"]
|
||||
edition = "2018"
|
||||
description = "A gemini server"
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::net::SocketAddr;
|
||||
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::io::AsyncRead;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::io::{AsyncWrite, AsyncWriteExt};
|
||||
use tokio_openssl::SslStream;
|
||||
|
||||
use crate::status::Status;
|
||||
@@ -35,6 +35,9 @@ impl Connection {
|
||||
if let Some(b) = body {
|
||||
self.send_raw(b.as_bytes()).await?;
|
||||
}
|
||||
|
||||
futures_util::future::poll_fn(|ctx| std::pin::Pin::new(&mut self.stream).poll_shutdown(ctx)).await.unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -46,6 +49,7 @@ impl Connection {
|
||||
|
||||
pub async fn send_stream<S: AsyncRead + Unpin>(&mut self, reader: &mut S) -> Result<(), io::Error> {
|
||||
tokio::io::copy(reader, &mut self.stream).await?;
|
||||
futures_util::future::poll_fn(|ctx| std::pin::Pin::new(&mut self.stream).poll_shutdown(ctx)).await.unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user