mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
Kernel: Handle SHUT_RDWR in Socket::shutdown
We were previously assuming that the how value was a bitfield, but that is not the case, so we must explicitly check for SHUT_RDWR when deciding on the read and write shutdowns.
This commit is contained in:
parent
a6f237a247
commit
020c898290
Notes:
sideshowbarker
2024-07-17 09:33:07 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/020c898290 Pull-request: https://github.com/SerenityOS/serenity/pull/14533 Reviewed-by: https://github.com/linusg ✅
1 changed files with 6 additions and 4 deletions
|
@ -256,12 +256,14 @@ ErrorOr<void> Socket::shutdown(int how)
|
||||||
return set_so_error(ENOTCONN);
|
return set_so_error(ENOTCONN);
|
||||||
if (m_role == Role::Listener)
|
if (m_role == Role::Listener)
|
||||||
return set_so_error(ENOTCONN);
|
return set_so_error(ENOTCONN);
|
||||||
if (!m_shut_down_for_writing && (how & SHUT_WR))
|
if (!m_shut_down_for_writing && (how == SHUT_WR || how == SHUT_RDWR)) {
|
||||||
shut_down_for_writing();
|
shut_down_for_writing();
|
||||||
if (!m_shut_down_for_reading && (how & SHUT_RD))
|
m_shut_down_for_writing = true;
|
||||||
|
}
|
||||||
|
if (!m_shut_down_for_reading && (how == SHUT_RD || how == SHUT_RDWR)) {
|
||||||
shut_down_for_reading();
|
shut_down_for_reading();
|
||||||
m_shut_down_for_reading |= (how & SHUT_RD) != 0;
|
m_shut_down_for_reading = true;
|
||||||
m_shut_down_for_writing |= (how & SHUT_WR) != 0;
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue