fix double drop on error of getting file metadata

This commit is contained in:
fakeshadow 2021-10-21 11:45:42 +08:00
parent 8c8746b732
commit f8032adfd5
2 changed files with 3 additions and 3 deletions

View File

@ -195,9 +195,9 @@ impl NamedFile {
// SAFETY: fd is borrowed and lives longer than the unsafe block.
unsafe {
let fs = std::fs::File::from_raw_fd(fd);
let md = fs.metadata()?;
let res = fs.metadata();
std::mem::forget(fs);
md
res?
}
}
};

View File

@ -96,7 +96,7 @@ impl fmt::Debug for FilesService {
impl Service<ServiceRequest> for FilesService {
type Response = ServiceResponse;
type Error = Error;
type Future = LocalBoxFuture<'static, Result<ServiceResponse, Error>>;
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
actix_service::always_ready!();