mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LookupServer: Be a little more robust in case accept() fails
This commit is contained in:
parent
5cbc9d5724
commit
489d413fc7
Notes:
sideshowbarker
2024-07-18 22:44:15 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/489d413fc7b
2 changed files with 6 additions and 4 deletions
|
@ -52,9 +52,11 @@ LookupServer::LookupServer()
|
|||
m_local_server = Core::LocalServer::construct(this);
|
||||
m_local_server->on_ready_to_accept = [this]() {
|
||||
auto socket = m_local_server->accept();
|
||||
if (!socket)
|
||||
return;
|
||||
socket->on_ready_to_read = [this, socket]() {
|
||||
service_client(socket);
|
||||
RefPtr<Core::LocalSocket> keeper = socket;
|
||||
service_client(*socket);
|
||||
NonnullRefPtr keeper = *socket;
|
||||
const_cast<Core::LocalSocket&>(*socket).on_ready_to_read = [] {};
|
||||
};
|
||||
};
|
||||
|
@ -97,7 +99,7 @@ void LookupServer::load_etc_hosts()
|
|||
}
|
||||
}
|
||||
|
||||
void LookupServer::service_client(RefPtr<Core::LocalSocket> socket)
|
||||
void LookupServer::service_client(NonnullRefPtr<Core::LocalSocket> socket)
|
||||
{
|
||||
u8 client_buffer[1024];
|
||||
int nrecv = socket->read(client_buffer, sizeof(client_buffer) - 1);
|
||||
|
|
|
@ -40,7 +40,7 @@ private:
|
|||
LookupServer();
|
||||
|
||||
void load_etc_hosts();
|
||||
void service_client(RefPtr<Core::LocalSocket>);
|
||||
void service_client(NonnullRefPtr<Core::LocalSocket>);
|
||||
Vector<String> lookup(const String& hostname, const String& nameserver, bool& did_get_response, unsigned short record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
||||
|
||||
struct CachedLookup {
|
||||
|
|
Loading…
Reference in a new issue