From baa26d10a87213dcaaff96fb246185de1dbfa22a Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 30 Oct 2023 12:22:38 -0600 Subject: [PATCH] LibTLS: Retry sending in TLSv12::flush() on EAGAIN or EINTR Crashing here is not very helpful. --- Userland/Libraries/LibTLS/Socket.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibTLS/Socket.cpp b/Userland/Libraries/LibTLS/Socket.cpp index b6ec2f5630e..e29eb737bc0 100644 --- a/Userland/Libraries/LibTLS/Socket.cpp +++ b/Userland/Libraries/LibTLS/Socket.cpp @@ -271,10 +271,13 @@ ErrorOr TLSv12::flush() size_t written; do { auto result = stream.write_some(out_bytes); - if (result.is_error() && result.error().code() != EINTR && result.error().code() != EAGAIN) { - error = result.release_error(); - dbgln("TLS Socket write error: {}", *error); - break; + if (result.is_error()) { + if (result.error().code() != EINTR && result.error().code() != EAGAIN) { + error = result.release_error(); + dbgln("TLS Socket write error: {}", *error); + break; + } + continue; } written = result.value(); out_bytes = out_bytes.slice(written);