mirror of
https://github.com/matrix-construct/construct
synced 2024-12-03 04:02:47 +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
|
bool
|
||||||
ircd::conf::item<void>::set(const string_view &val)
|
ircd::conf::item<void>::set(const string_view &val)
|
||||||
{
|
{
|
||||||
const bool ret
|
std::string existing(get()); try
|
||||||
{
|
|
||||||
on_set(val)
|
|
||||||
};
|
|
||||||
|
|
||||||
if(set_cb) try
|
|
||||||
{
|
{
|
||||||
|
if(on_set(val))
|
||||||
|
if(set_cb)
|
||||||
set_cb();
|
set_cb();
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(...)
|
||||||
{
|
{
|
||||||
log::error
|
on_set(existing);
|
||||||
{
|
throw;
|
||||||
"conf item[%s] set callback :%s", e.what()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -262,7 +257,7 @@ const
|
||||||
bool
|
bool
|
||||||
ircd::conf::item<void>::on_set(const string_view &)
|
ircd::conf::item<void>::on_set(const string_view &)
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::string_view
|
ircd::string_view
|
||||||
|
|
Loading…
Reference in a new issue