From: Otto Date: Mon, 29 Mar 2021 10:07:14 +0000 (+0200) Subject: Move the opening of the file to write a bit down X-Git-Tag: rec-4.4.3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8096deb0420f5d7d1f869aff8e9d3cb35489bad5;p=thirdparty%2Fpdns.git Move the opening of the file to write a bit down (cherry picked from commit 5ef38b0c7b61e819773765d87b0fe6061cd0be7a) --- diff --git a/pdns/nod.cc b/pdns/nod.cc index 45d295e27e..af86697ddc 100644 --- a/pdns/nod.cc +++ b/pdns/nod.cc @@ -46,7 +46,7 @@ void PersistentSBF::remove_tmp_files() Regex file_regex(d_prefix + ".*\\." + bf_suffix + "\\.[[:xdigit:]]{8}$"); for (filesystem::directory_iterator i(p); i != filesystem::directory_iterator(); ++i) { if (filesystem::is_regular_file(i->path()) && file_regex.match(i->path().filename().string())) { - remove(*i); + filesystem::remove(*i); } } } @@ -64,7 +64,7 @@ bool PersistentSBF::init(bool ignore_pid) { if (d_cachedir.length()) { filesystem::path p(d_cachedir); try { - if (exists(p) && is_directory(p)) { + if (filesystem::exists(p) && filesystem::is_directory(p)) { remove_tmp_files(); filesystem::path newest_file; std::time_t newest_time=time(nullptr); @@ -95,11 +95,11 @@ bool PersistentSBF::init(bool ignore_pid) { // now dump it out again with new thread id & process id snapshotCurrent(std::this_thread::get_id()); // Remove the old file we just read to stop proliferation - remove(newest_file); + filesystem::remove(newest_file); } catch (const std::runtime_error& e) { infile.close(); - remove(newest_file); + filesystem::remove(newest_file); g_log< lock(d_sbf_mutex); d_sbf.dump(iss); } // Now write it out to the file + ofile.open(ftmp.string(), std::ios::out | std::ios::binary); ofile << iss.str(); if (ofile.fail()) {