mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
LibIPC: Make noise when shutting down because of an error
Previously, an IPC connection error could shut down the entire process without giving a hint as to what's wrong. Now, we report that error to the debug console.
This commit is contained in:
parent
1f736ced08
commit
a39c38840e
3 changed files with 11 additions and 7 deletions
|
@ -39,8 +39,7 @@ ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer)
|
|||
#ifdef __serenity__
|
||||
for (auto& fd : buffer.fds) {
|
||||
if (auto result = m_socket->send_fd(fd.value()); result.is_error()) {
|
||||
dbgln("{}", result.error());
|
||||
shutdown();
|
||||
shutdown_with_error(result.error());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -55,15 +54,13 @@ ErrorOr<void> ConnectionBase::post_message(MessageBuffer buffer)
|
|||
if (maybe_nwritten.is_error()) {
|
||||
auto error = maybe_nwritten.release_error();
|
||||
if (error.is_errno()) {
|
||||
shutdown_with_error(error);
|
||||
switch (error.code()) {
|
||||
case EPIPE:
|
||||
shutdown();
|
||||
return Error::from_string_literal("IPC::Connection::post_message: Disconnected from peer"sv);
|
||||
case EAGAIN:
|
||||
shutdown();
|
||||
return Error::from_string_literal("IPC::Connection::post_message: Peer buffer overflowed"sv);
|
||||
default:
|
||||
shutdown();
|
||||
return Error::from_syscall("IPC::Connection::post_message write"sv, -error.code());
|
||||
}
|
||||
} else {
|
||||
|
@ -84,6 +81,12 @@ void ConnectionBase::shutdown()
|
|||
die();
|
||||
}
|
||||
|
||||
void ConnectionBase::shutdown_with_error(Error const& error)
|
||||
{
|
||||
dbgln("IPC::ConnectionBase ({:p}) had an error ({}), disconnecting.", this, error);
|
||||
shutdown();
|
||||
}
|
||||
|
||||
void ConnectionBase::handle_messages()
|
||||
{
|
||||
auto messages = move(m_unprocessed_messages);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue