summaryrefslogtreecommitdiff
path: root/Libraries/LibCore
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-06 23:11:55 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-06 23:17:10 +0200
commit41066b009f69a3eaf3ad3196a2ff959853cc9321 (patch)
tree03966bd89c8ceb5dd9a74207666993325615ad39 /Libraries/LibCore
parente5933ec739aa9b896b2c7bb5aa8e7457b343adf4 (diff)
downloadserenity-41066b009f69a3eaf3ad3196a2ff959853cc9321.zip
LibCore: Don't fire Socket::on_ready_to_read if !can_read()
This is a bit of a pickle and I'm unsure what's the best behavior here. Since notifiers fire asynchronously via the event loop, we may end up firing a notifier for a socket fd, but then reading/writing that socket fd before ending up in the notifier callback. In that situation, the socket is no longer in the same state as it was when the event loop generated the notifier event. This patch stops Socket from firing one hook in this situation but this probably needs a global rethink. With this change, Browser starts reliably in multi-process mode. :^)
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r--Libraries/LibCore/Socket.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Libraries/LibCore/Socket.cpp b/Libraries/LibCore/Socket.cpp
index e5d5411829..c8f07672f2 100644
--- a/Libraries/LibCore/Socket.cpp
+++ b/Libraries/LibCore/Socket.cpp
@@ -204,6 +204,8 @@ void Socket::ensure_read_notifier()
ASSERT(m_connected);
m_read_notifier = Notifier::construct(fd(), Notifier::Event::Read, this);
m_read_notifier->on_ready_to_read = [this] {
+ if (!can_read())
+ return;
if (on_ready_to_read)
on_ready_to_read();
};