summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-07-09 22:29:50 +0300
committerAndreas Kling <kling@serenityos.org>2022-07-10 14:24:34 +0200
commit020c89829072c081d5c5c6e944705c8eb73292e5 (patch)
tree7e2b42519b093c6d5e85b3a113016263f6719b16 /Kernel
parenta6f237a247886ff9e1cb03ae15cd797e452355f1 (diff)
downloadserenity-020c89829072c081d5c5c6e944705c8eb73292e5.zip
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.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Net/Socket.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index 6f89a610a7..7a46ba1d0f 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -256,12 +256,14 @@ ErrorOr<void> Socket::shutdown(int how)
return set_so_error(ENOTCONN);
if (m_role == Role::Listener)
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();
- 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();
- m_shut_down_for_reading |= (how & SHUT_RD) != 0;
- m_shut_down_for_writing |= (how & SHUT_WR) != 0;
+ m_shut_down_for_reading = true;
+ }
return {};
}