0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-28 17:52:54 +01:00

ircd::db::database::env: Fix missing at-end semantics for ReopenWritableFile().

This commit is contained in:
Jason Volk 2022-06-23 09:38:46 -07:00
parent 61d558fc9d
commit 65d27f327e
2 changed files with 12 additions and 9 deletions

View file

@ -121,9 +121,9 @@ noexcept try
#endif #endif
if(options.use_direct_writes) if(options.use_direct_writes)
*r = std::make_unique<writable_file_direct>(&d, name, options, true); *r = std::make_unique<writable_file_direct>(&d, name, options, true, false);
else else
*r = std::make_unique<writable_file>(&d, name, options, true); *r = std::make_unique<writable_file>(&d, name, options, true, false);
return Status::OK(); return Status::OK();
} }
@ -155,9 +155,9 @@ noexcept try
#endif #endif
if(options.use_direct_writes) if(options.use_direct_writes)
*r = std::make_unique<writable_file_direct>(&d, name, options, false); *r = std::make_unique<writable_file_direct>(&d, name, options, false, true);
else else
*r = std::make_unique<writable_file>(&d, name, options, false); *r = std::make_unique<writable_file>(&d, name, options, false, true);
return Status::OK(); return Status::OK();
} }
@ -1244,7 +1244,8 @@ ircd::db::database::env::make_nice(const IOPriority &prio)
ircd::db::database::env::writable_file::writable_file(database *const &d, ircd::db::database::env::writable_file::writable_file(database *const &d,
const std::string &name, const std::string &name,
const EnvOptions &env_opts, const EnvOptions &env_opts,
const bool &trunc) const bool &trunc,
const bool &ate)
try try
:d :d
{ {
@ -1257,6 +1258,7 @@ try
,opts ,opts
{ {
.mode = std::ios::out | (trunc? std::ios::trunc : std::ios::openmode(0)), .mode = std::ios::out | (trunc? std::ios::trunc : std::ios::openmode(0)),
.ate = ate,
.direct = this->env_opts.use_direct_writes, .direct = this->env_opts.use_direct_writes,
.cloexec = this->env_opts.set_fd_cloexec, .cloexec = this->env_opts.set_fd_cloexec,
.dontneed = true, .dontneed = true,
@ -2220,10 +2222,11 @@ catch(...)
ircd::db::database::env::writable_file_direct::writable_file_direct(database *const &d, ircd::db::database::env::writable_file_direct::writable_file_direct(database *const &d,
const std::string &name, const std::string &name,
const EnvOptions &env_opts, const EnvOptions &env_opts,
const bool &trunc) const bool &trunc,
const bool &ate)
:writable_file :writable_file
{ {
d, name, env_opts, trunc d, name, env_opts, trunc, ate
} }
,alignment ,alignment
{ {

View file

@ -253,7 +253,7 @@ ircd::db::database::env::writable_file
Status Flush() noexcept override; Status Flush() noexcept override;
Status Close() noexcept override; Status Close() noexcept override;
writable_file(database *const &d, const std::string &name, const EnvOptions &, const bool &trunc); writable_file(database *const &d, const std::string &name, const EnvOptions &, const bool &trunc, const bool &ate);
writable_file(const writable_file &) = delete; writable_file(const writable_file &) = delete;
writable_file(writable_file &&) = delete; writable_file(writable_file &&) = delete;
~writable_file() noexcept; ~writable_file() noexcept;
@ -291,5 +291,5 @@ ircd::db::database::env::writable_file_direct final
Status Truncate(uint64_t size) noexcept override; Status Truncate(uint64_t size) noexcept override;
Status Close() noexcept override; Status Close() noexcept override;
writable_file_direct(database *const &d, const std::string &name, const EnvOptions &, const bool &trunc); writable_file_direct(database *const &d, const std::string &name, const EnvOptions &, const bool &trunc, const bool &ate);
}; };