From fca2d8ed8205aae8a917ac57e412a78a489b9c25 Mon Sep 17 00:00:00 2001 From: "Brian L. Troutwine" Date: Tue, 1 Oct 2024 12:04:14 -0700 Subject: [PATCH] Drop file handle just to be extra certain This commit drops `fp` whenever we flush it and overwrite `fp`. This is implied by the overwrite, of course, but I found myself wondering about when exactly this operation took place, so now it's explicit. Signed-off-by: Brian L. Troutwine --- lading/src/generator/file_gen/logrotate.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lading/src/generator/file_gen/logrotate.rs b/lading/src/generator/file_gen/logrotate.rs index 6b0489189..35905c457 100644 --- a/lading/src/generator/file_gen/logrotate.rs +++ b/lading/src/generator/file_gen/logrotate.rs @@ -307,6 +307,7 @@ impl Child { if total_bytes_written > maximum_bytes_per_log { fp.flush().await?; + drop(fp); // Delete the last name file, if it exists. Move all files to their next highest. if fs::try_exists(&last_name).await? { @@ -339,6 +340,8 @@ impl Child { } () = &mut shutdown_wait => { fp.flush().await?; + drop(fp); + info!("shutdown signal received"); return Ok(()); },