mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-07 09:31:53 +00: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:
parent
8b3355ed0d
commit
36da270dbe
Notes:
github-actions[bot]
2025-05-21 10:56:21 +00:00
Author: https://github.com/trflynn89
Commit: 36da270dbe
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4828
Reviewed-by: https://github.com/shannonbooth ✅
3 changed files with 85 additions and 36 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue