From d82c82db2cd07fa4e5f7fa669d72dd618c89ed16 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 31 Aug 2024 17:19:52 -0400 Subject: [PATCH] Add sleep in handle_EINTR --- httplib.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index c777991..2bdae5d 100644 --- a/httplib.h +++ b/httplib.h @@ -2951,7 +2951,10 @@ template inline ssize_t handle_EINTR(T fn) { ssize_t res = 0; while (true) { res = fn(); - if (res < 0 && errno == EINTR) { continue; } + if (res < 0 && errno == EINTR) { + std::this_thread::sleep_for(std::chrono::milliseconds{1}); + continue; + } break; } return res;