Skip to content

Commit

Permalink
ZTS: close in mmapwrite.c
Browse files Browse the repository at this point in the history
commit a7304ab upstream

mmapwrite is used during the ZTS to identify issues with mmap-ed files.
This helper program exercises this pathway by continuously writing to a
file.  ee6bf97 modified the writing threads to terminate after a set
amount of total data is written.  This change allows standard program
execution to reach the end of a writer thread without closing the file
descriptor, introducing a resource "leak."

This patch appeases resource leak analyses by close()-ing the file at
the end of the thread.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #14353
  • Loading branch information
aerusso authored and behlendorf committed Jan 10, 2023
1 parent a75af54 commit 5371d8d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/zfs-tests/cmd/mmapwrite/mmapwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ normal_writer(void *filename)
if (buf) {
free(buf);
}

if (close(fd) != 0)
err(1, "failed to close file");

return (NULL);
}

Expand Down

0 comments on commit 5371d8d

Please sign in to comment.