mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibCore: Properly shutdown a socket on Windows
It fixes a bug in which ImageDecoder and RequestServer do not exit because their connections don't close. This makes the shutdown behavior match the Linux version, which receives FD_READ | FD_HANGUP on socket close, and TransportSocket::read_as_much_as_possible_without_blocking calls schedule_shutdown when read from a socket returns 0 bytes. On Windows, we have to explicitly call WIN32 shutdown to receive notification FD_CLOSE.
This commit is contained in:
parent
e1f70d532c
commit
26825b5865
Notes:
github-actions[bot]
2025-02-10 19:47:21 +00:00
Author: https://github.com/stasoid Commit: https://github.com/LadybirdBrowser/ladybird/commit/26825b58651 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3493 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/R-Goc Reviewed-by: https://github.com/konradekk Reviewed-by: https://github.com/trflynn89
2 changed files with 3 additions and 1 deletions
|
@ -150,7 +150,7 @@ static int notifier_type_to_network_event(NotificationType type)
|
|||
{
|
||||
switch (type) {
|
||||
case NotificationType::Read:
|
||||
return FD_READ;
|
||||
return FD_READ | FD_CLOSE;
|
||||
case NotificationType::Write:
|
||||
return FD_WRITE;
|
||||
default:
|
||||
|
|
|
@ -122,6 +122,8 @@ void PosixSocketHelper::close()
|
|||
if (m_notifier)
|
||||
m_notifier->set_enabled(false);
|
||||
|
||||
// shutdown is required for another end to receive FD_CLOSE
|
||||
shutdown(m_fd, SD_BOTH);
|
||||
MUST(System::close(m_fd));
|
||||
m_fd = -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue