diff --git a/kernel/kernel/OpenFileDescriptorSet.cpp b/kernel/kernel/OpenFileDescriptorSet.cpp index bd55a0a2..9f0f35f0 100644 --- a/kernel/kernel/OpenFileDescriptorSet.cpp +++ b/kernel/kernel/OpenFileDescriptorSet.cpp @@ -544,33 +544,14 @@ namespace Kernel } LockGuard _(inode->m_mutex); - - const auto check_errors = - [&inode, is_nonblock]() -> BAN::ErrorOr - { - if (inode->has_hungup()) - { - Thread::current().add_signal(SIGPIPE); - return BAN::Error::from_errno(EPIPE); - } - if (is_nonblock && !inode->can_write()) - return BAN::Error::from_errno(EWOULDBLOCK); - return {}; - }; - - TRY(check_errors()); - - size_t total_sent = 0; - while (total_sent < buffer.size()) + if (inode->has_hungup()) { - TRY(check_errors()); - const size_t nsend = TRY(inode->sendto(buffer.slice(total_sent), address, address_len)); - if (nsend == 0) - return 0; - total_sent += nsend; + Thread::current().add_signal(SIGPIPE); + return BAN::Error::from_errno(EPIPE); } - - return total_sent; + if (is_nonblock && !inode->can_write()) + return BAN::Error::from_errno(EWOULDBLOCK); + return inode->sendto(buffer, address, address_len); } BAN::ErrorOr OpenFileDescriptorSet::file_of(int fd) const