mirror of
https://github.com/matrix-construct/construct
synced 2024-12-01 19:22:53 +01:00
ircd::conf: Revert conf item if setter or set callback fails.
This commit is contained in:
parent
1fa5ebc415
commit
499d9c7c6e
1 changed files with 9 additions and 14 deletions
21
ircd/conf.cc
21
ircd/conf.cc
|
@ -221,24 +221,19 @@ noexcept
|
|||
bool
|
||||
ircd::conf::item<void>::set(const string_view &val)
|
||||
{
|
||||
const bool ret
|
||||
{
|
||||
on_set(val)
|
||||
};
|
||||
|
||||
if(set_cb) try
|
||||
std::string existing(get()); try
|
||||
{
|
||||
if(on_set(val))
|
||||
if(set_cb)
|
||||
set_cb();
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
catch(...)
|
||||
{
|
||||
log::error
|
||||
{
|
||||
"conf item[%s] set callback :%s", e.what()
|
||||
};
|
||||
on_set(existing);
|
||||
throw;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string
|
||||
|
@ -262,7 +257,7 @@ const
|
|||
bool
|
||||
ircd::conf::item<void>::on_set(const string_view &)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
|
|
Loading…
Reference in a new issue