LibTLS: Retry sending in TLSv12::flush() on EAGAIN or EINTR

Crashing here is not very helpful.
This commit is contained in:
Andrew Kaster 2023-10-30 12:22:38 -06:00 committed by Ali Mohammad Pur
parent c93d367d95
commit baa26d10a8
Notes: sideshowbarker 2024-07-17 18:46:57 +09:00

View file

@ -271,10 +271,13 @@ ErrorOr<bool> TLSv12::flush()
size_t written; size_t written;
do { do {
auto result = stream.write_some(out_bytes); auto result = stream.write_some(out_bytes);
if (result.is_error() && result.error().code() != EINTR && result.error().code() != EAGAIN) { if (result.is_error()) {
error = result.release_error(); if (result.error().code() != EINTR && result.error().code() != EAGAIN) {
dbgln("TLS Socket write error: {}", *error); error = result.release_error();
break; dbgln("TLS Socket write error: {}", *error);
break;
}
continue;
} }
written = result.value(); written = result.value();
out_bytes = out_bytes.slice(written); out_bytes = out_bytes.slice(written);