LibIPC: Move notifier handling entirely to IPC::Connection base class

This commit is contained in:
Andreas Kling 2020-09-12 13:03:39 +02:00
parent 54116115a8
commit 4873e2bb53
Notes: sideshowbarker 2024-07-19 02:43:44 +09:00
3 changed files with 5 additions and 31 deletions

View file

@ -26,20 +26,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
#include <LibCore/LocalSocket.h>
#include <LibCore/Object.h>
#include <LibCore/Timer.h>
#include <LibIPC/Connection.h>
#include <LibIPC/Endpoint.h>
#include <LibIPC/Message.h>
#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
namespace IPC {

View file

@ -29,6 +29,7 @@
#include <AK/ByteBuffer.h>
#include <AK/NonnullOwnPtrVector.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
#include <LibCore/LocalSocket.h>
#include <LibCore/Notifier.h>
#include <LibCore/SyscallUtils.h>
@ -52,6 +53,10 @@ public:
, m_notifier(Core::Notifier::construct(m_socket->fd(), Core::Notifier::Read, this))
{
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
m_notifier->on_ready_to_read = [this] {
drain_messages_from_peer();
handle_messages();
};
}
pid_t peer_pid() const { return m_peer_pid; }
@ -118,7 +123,6 @@ public:
protected:
Core::LocalSocket& socket() { return *m_socket; }
Core::Notifier& notifier() { return *m_notifier; }
void set_peer_pid(pid_t pid) { m_peer_pid = pid; }
template<typename MessageType, typename Endpoint>

View file

@ -26,20 +26,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/NonnullOwnPtrVector.h>
#include <LibCore/Event.h>
#include <LibCore/LocalSocket.h>
#include <LibCore/Notifier.h>
#include <LibCore/SyscallUtils.h>
#include <LibIPC/Connection.h>
#include <LibIPC/Message.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
namespace IPC {
@ -51,10 +38,6 @@ public:
{
// We want to rate-limit our clients
this->socket().set_blocking(true);
this->notifier().on_ready_to_read = [this] {
this->drain_messages_from_peer();
this->handle_messages();
};
if (!this->socket().connect(Core::SocketAddress::local(address))) {
perror("connect");