Skip to content

Commit 11b8bbe

Browse files
ayeteadoegmta
authored andcommitted
LibCore: Use correct fd for NotifierActivationEvent on Windows
The initial IOCP event loop implementation had a fd() method for the EventLoopNotifier packet that did not actually return the fd for the notifier, but a to_fd() call on an object HANDLE that was always NULL. This meant we were always posting NotifierActivationEvents with a fd of 0. This rendered all of our WinSock2 I/O invalid, meaning no IPC messages would ever be successfully sent or received.
1 parent 7d2f631 commit 11b8bbe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Libraries/LibCore/EventLoopImplementationWindows.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ struct EventLoopNotifier final : CompletionPacket {
9292
}
9393

9494
Notifier::Type notifier_type() const { return m_notifier_type; }
95-
int fd() const { return to_fd(object_handle); }
95+
int notifier_fd() const { return m_notifier_fd; }
9696

9797
// These are a space tradeoff for avoiding a double indirection through the notifier*.
9898
Notifier* notifier;
9999
Notifier::Type m_notifier_type;
100-
HANDLE object_handle;
100+
int m_notifier_fd { -1 };
101101
OwnHandle wait_packet;
102102
OwnHandle wait_event;
103103
};
@@ -187,8 +187,8 @@ size_t EventLoopImplementationWindows::pump(PumpMode pump_mode)
187187
continue;
188188
}
189189
if (packet->type == CompletionType::Notifer) {
190-
auto* notifier_data = reinterpret_cast<EventLoopNotifier*>(packet);
191-
event_queue.post_event(*notifier_data->notifier, make<NotifierActivationEvent>(notifier_data->fd(), notifier_data->notifier_type()));
190+
auto* notifier_data = static_cast<EventLoopNotifier*>(packet);
191+
event_queue.post_event(*notifier_data->notifier, make<NotifierActivationEvent>(notifier_data->notifier_fd(), notifier_data->notifier_type()));
192192
g_system.NtAssociateWaitCompletionPacket(notifier_data->wait_packet.handle, thread_data->iocp.handle, notifier_data->wait_event.handle, notifier_data, NULL, 0, 0, NULL);
193193
continue;
194194
}

0 commit comments

Comments
 (0)