0
0
Fork 0
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:
Jason Volk 2019-03-11 11:17:35 -07:00
parent 1fa5ebc415
commit 499d9c7c6e

View file

@ -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