mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-03 16:22:35 +03:00
Return error codes instead of throwing exception
Changed server_state public methods sst_received() and wait_until_state() to report errors as return value instead of throwing exceptions. This was done to gradually get rid of public methods which report errors via exceptions. This change was part of MDEV-30419.
This commit is contained in:
@ -703,8 +703,9 @@ void wsrep::server_state::sst_sent(const wsrep::gtid& gtid, int error)
|
||||
}
|
||||
}
|
||||
|
||||
void wsrep::server_state::sst_received(wsrep::client_service& cs,
|
||||
int wsrep::server_state::sst_received(wsrep::client_service& cs,
|
||||
int const error)
|
||||
try
|
||||
{
|
||||
wsrep::log_info() << "SST received";
|
||||
wsrep::gtid gtid(wsrep::gtid::undefined());
|
||||
@ -800,10 +801,20 @@ void wsrep::server_state::sst_received(wsrep::client_service& cs,
|
||||
enum provider::status const retval(provider().sst_received(gtid, error));
|
||||
if (retval != provider::success)
|
||||
{
|
||||
std::string msg("wsrep::sst_received() failed: ");
|
||||
msg += wsrep::provider::to_string(retval);
|
||||
throw wsrep::runtime_error(msg);
|
||||
wsrep::log_error() << "provider.sst_received() failed: "
|
||||
<< wsrep::provider::to_string(retval);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (const wsrep::runtime_error& e)
|
||||
{
|
||||
wsrep::log_error() << "sst_received failed: " << e.what();
|
||||
if (provider_)
|
||||
{
|
||||
provider_->sst_received(wsrep::gtid::undefined(), -EINTR);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void wsrep::server_state::initialized()
|
||||
@ -1388,6 +1399,18 @@ void wsrep::server_state::wait_until_state(
|
||||
cond_.notify_all();
|
||||
}
|
||||
|
||||
int wsrep::server_state::wait_until_state(enum state state) const
|
||||
try
|
||||
{
|
||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||
wait_until_state(lock, state);
|
||||
return 0;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void wsrep::server_state::interrupt_state_waiters(
|
||||
wsrep::unique_lock<wsrep::mutex>& lock WSREP_UNUSED)
|
||||
{
|
||||
|
Reference in New Issue
Block a user