summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-12 13:03:39 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-12 14:49:29 +0200
commit4873e2bb5341edbb58259c5cf917f89c1e911190 (patch)
tree58e33389880fb7b9876edbbe65b17551aa6242bb
parent54116115a8464015c8967b27927333482ff97cc4 (diff)
downloadserenity-4873e2bb5341edbb58259c5cf917f89c1e911190.zip
LibIPC: Move notifier handling entirely to IPC::Connection base class
-rw-r--r--Libraries/LibIPC/ClientConnection.h13
-rw-r--r--Libraries/LibIPC/Connection.h6
-rw-r--r--Libraries/LibIPC/ServerConnection.h17
3 files changed, 5 insertions, 31 deletions
diff --git a/Libraries/LibIPC/ClientConnection.h b/Libraries/LibIPC/ClientConnection.h
index 2b042db22d..e82eed702e 100644
--- a/Libraries/LibIPC/ClientConnection.h
+++ b/Libraries/LibIPC/ClientConnection.h
@@ -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 {
diff --git a/Libraries/LibIPC/Connection.h b/Libraries/LibIPC/Connection.h
index 4a901f6146..452bd22a02 100644
--- a/Libraries/LibIPC/Connection.h
+++ b/Libraries/LibIPC/Connection.h
@@ -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>
diff --git a/Libraries/LibIPC/ServerConnection.h b/Libraries/LibIPC/ServerConnection.h
index 456d29964b..f90fddccfc 100644
--- a/Libraries/LibIPC/ServerConnection.h
+++ b/Libraries/LibIPC/ServerConnection.h
@@ -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");