Commit Diff


commit - 3499712b1b7c25c2508044f857ab80055d878e52
commit + 24a5a6ec4dc24f78834a3e638a297cb9024f008d
blob - 7421e7e61bd03408033cc994362ed5e6ca6ffd13
blob + 2fd64c41da913b79b2baa6ed432aa0e4cd956d41
--- vostok/transport.cc
+++ vostok/transport.cc
@@ -175,6 +175,7 @@ send(
     /* in */ Span<const char> buff
 )
 {
+    auto workaround = 0;
     while (buff.size() > 0)
     {
         auto ret = tls_write(ctx, buff.begin(), buff.size());
@@ -186,11 +187,21 @@ send(
             return false;
         }
 
-        buff = buff.subspan(ret);
-        if (buff.size() <= 0)
-            break;
+        if (ret == 0)
+        {
+            ++workaround;
+            if (workaround > 1000)
+            {
+                error::occurred("TLS write (infinite loop check)", PrintIfError{tls_error(ctx)});
+                return false;
+            }
+        }
+        else
+        {
+            workaround = 0;
+        }
 
-        error::g_log << "tls_write() == " << std::dec << ret << " ";
+        buff = buff.subspan(ret);
     }
     return true;
 }