mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +00:00
LibWebSocket: Use deferred_invoke() when discarding a connection
We don't want to destroy the WebSocketImpl while we're still using it higher up the stack. By using deferred_invoke(), we allow the stack to unwind before actually destroying any objects. This fixes an issue with the WebSocket service crashing on immediate connection failure.
This commit is contained in:
parent
f82c4c4137
commit
1735d978ed
1 changed files with 8 additions and 6 deletions
|
@ -565,12 +565,14 @@ void WebSocket::fatal_error(WebSocket::Error error)
|
|||
|
||||
void WebSocket::discard_connection()
|
||||
{
|
||||
VERIFY(m_impl);
|
||||
m_impl->discard_connection();
|
||||
m_impl->on_connection_error = nullptr;
|
||||
m_impl->on_connected = nullptr;
|
||||
m_impl->on_ready_to_read = nullptr;
|
||||
m_impl = nullptr;
|
||||
deferred_invoke([this] {
|
||||
VERIFY(m_impl);
|
||||
m_impl->discard_connection();
|
||||
m_impl->on_connection_error = nullptr;
|
||||
m_impl->on_connected = nullptr;
|
||||
m_impl->on_ready_to_read = nullptr;
|
||||
m_impl = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
void WebSocket::notify_open()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue