mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibCore: Do not assert that we can start the RPC server
Now that the Shell uses Core::EventLoop, we can't afford to just crash if /tmp is unwritable.
This commit is contained in:
parent
53647e347f
commit
8afcf0d87a
3 changed files with 22 additions and 15 deletions
|
@ -233,20 +233,10 @@ EventLoop::EventLoop()
|
||||||
ASSERT(rc == 0);
|
ASSERT(rc == 0);
|
||||||
s_event_loop_stack->append(this);
|
s_event_loop_stack->append(this);
|
||||||
|
|
||||||
auto rpc_path = String::format("/tmp/rpc.%d", getpid());
|
if (!s_rpc_server) {
|
||||||
rc = unlink(rpc_path.characters());
|
if (!start_rpc_server())
|
||||||
if (rc < 0 && errno != ENOENT) {
|
dbg() << "Core::EventLoop: Failed to start an RPC server";
|
||||||
perror("unlink");
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
s_rpc_server = LocalServer::construct();
|
|
||||||
s_rpc_server->set_name("Core::EventLoop_RPC_server");
|
|
||||||
bool listening = s_rpc_server->listen(rpc_path);
|
|
||||||
ASSERT(listening);
|
|
||||||
|
|
||||||
s_rpc_server->on_ready_to_accept = [&] {
|
|
||||||
RPCClient::construct(s_rpc_server->accept());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CEVENTLOOP_DEBUG
|
#ifdef CEVENTLOOP_DEBUG
|
||||||
|
@ -258,6 +248,22 @@ EventLoop::~EventLoop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EventLoop::start_rpc_server()
|
||||||
|
{
|
||||||
|
auto rpc_path = String::format("/tmp/rpc.%d", getpid());
|
||||||
|
int rc = unlink(rpc_path.characters());
|
||||||
|
if (rc < 0 && errno != ENOENT) {
|
||||||
|
perror("unlink");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_rpc_server = LocalServer::construct();
|
||||||
|
s_rpc_server->set_name("Core::EventLoop_RPC_server");
|
||||||
|
s_rpc_server->on_ready_to_accept = [&] {
|
||||||
|
RPCClient::construct(s_rpc_server->accept());
|
||||||
|
};
|
||||||
|
return s_rpc_server->listen(rpc_path);
|
||||||
|
}
|
||||||
|
|
||||||
EventLoop& EventLoop::main()
|
EventLoop& EventLoop::main()
|
||||||
{
|
{
|
||||||
ASSERT(s_main_event_loop);
|
ASSERT(s_main_event_loop);
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
static void wake();
|
static void wake();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool start_rpc_server();
|
||||||
void wait_for_event(WaitMode);
|
void wait_for_event(WaitMode);
|
||||||
Optional<struct timeval> get_next_timer_expiration();
|
Optional<struct timeval> get_next_timer_expiration();
|
||||||
|
|
||||||
|
|
|
@ -123,13 +123,13 @@ bool LocalServer::listen(const String& address)
|
||||||
rc = ::bind(m_fd, (const sockaddr*)&un, sizeof(un));
|
rc = ::bind(m_fd, (const sockaddr*)&un, sizeof(un));
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
ASSERT_NOT_REACHED();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ::listen(m_fd, 5);
|
rc = ::listen(m_fd, 5);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("listen");
|
perror("listen");
|
||||||
ASSERT_NOT_REACHED();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_listening = true;
|
m_listening = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue