Commit 4b70b7dd for tesseract

commit 4b70b7dd68c0c530d6b665d90961b8a4f15d697e
Author: Ramya-9353 <ramya@digiscrypt.com>
Date:   Thu Jul 16 22:24:27 2026 +0530

    Handle send() failures in SVNetwork::Flush (#4576)

    Handle send() failures in SVNetwork::Flush().

    This change avoids removing data from the outgoing buffer when send() fails
    and retries interrupted send() calls (EINTR) on POSIX systems.

    Reviewed-by: Stefan Weil <sw@weilnetz.de>

diff --git a/src/viewer/svutil.cpp b/src/viewer/svutil.cpp
index c86594cd..034ddd01 100644
--- a/src/viewer/svutil.cpp
+++ b/src/viewer/svutil.cpp
@@ -168,8 +168,23 @@ void SVNetwork::Send(const char *msg) {
 void SVNetwork::Flush() {
   std::lock_guard<std::mutex> guard(mutex_send_);
   while (!msg_buffer_out_.empty()) {
-    int i = send(stream_, msg_buffer_out_.c_str(), msg_buffer_out_.length(), 0);
-    msg_buffer_out_.erase(0, i);
+    int i =
+        send(stream_, msg_buffer_out_.c_str(), msg_buffer_out_.length(), 0);
+
+    if (i < 0) {
+#ifndef _WIN32
+      if (errno == EINTR) {
+        continue;
+      }
+#endif
+      break;
+    }
+
+    if (i == 0) {
+      break;
+    }
+
+    msg_buffer_out_.erase(0, static_cast<std::string::size_type>(i));
   }
 }