Merge branch 'fsync-shadow-files-before-rename' of https://github.com/awelzel/zeek

* 'fsync-shadow-files-before-rename' of https://github.com/awelzel/zeek:
  logging/writers/ascii: shadow files: Add fsync() before rename()
This commit is contained in:
Johanna Amann 2021-10-15 09:21:42 +01:00
commit 1b3b9a3cfc
5 changed files with 45 additions and 3 deletions

View file

@ -465,7 +465,7 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
if ( sfd < 0 )
{
Error(Fmt("cannot open %s: %s", sfname.data(), Strerror(errno)));
Error(Fmt("cannot open %s: %s", tmp_sfname.data(), Strerror(errno)));
return false;
}
@ -478,7 +478,7 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
util::safe_write(sfd, ppf, strlen(ppf));
util::safe_write(sfd, "\n", 1);
util::safe_fsync(sfd);
util::safe_close(sfd);
if ( rename(tmp_sfname.data(), sfname.data()) == -1 )