Skip to content

Commit

Permalink
Drop file handle just to be extra certain
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
blt committed Oct 2, 2024
1 parent 33feb50 commit fca2d8e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lading/src/generator/file_gen/logrotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down Expand Up @@ -339,6 +340,8 @@ impl Child {
}
() = &mut shutdown_wait => {
fp.flush().await?;
drop(fp);

info!("shutdown signal received");
return Ok(());
},
Expand Down

0 comments on commit fca2d8e

Please sign in to comment.