mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 20:17:13 +02:00
LibIPC+LibWeb: Flush MessagePort messages before closing
The spec isn't super clear on what disentagling a MessagePort means. But we are required to send all pending messages before closing the port. This is a bit tricky because the transport socket performs writes on a background thread. From the main thread, where the disentanglement will occur, we don't really know the state of the write thread. So what we do here is stop the background thread then flush all remaining data from the main thread.
This commit is contained in:
Notes:
github-actions[bot]
2025-05-21 10:56:21 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/36da270dbef Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4828 Reviewed-by: https://github.com/shannonbooth ✅
@@ -146,11 +146,15 @@ WebIDL::ExceptionOr<void> MessagePort::transfer_receiving_steps(HTML::TransferDa
|
||||
|
||||
void MessagePort::disentangle()
|
||||
{
|
||||
if (m_remote_port)
|
||||
if (m_remote_port) {
|
||||
m_remote_port->m_remote_port = nullptr;
|
||||
m_remote_port = nullptr;
|
||||
m_remote_port = nullptr;
|
||||
}
|
||||
|
||||
m_transport.clear();
|
||||
if (m_transport) {
|
||||
m_transport->close_after_sending_all_pending_messages();
|
||||
m_transport.clear();
|
||||
}
|
||||
|
||||
m_worker_event_target = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user